Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ com.azure.resourcemanager:azure-resourcemanager-datadog;1.0.0-beta.3;1.0.0-beta.
com.azure.resourcemanager:azure-resourcemanager-communication;1.0.0;1.1.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-apimanagement;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-kubernetesconfiguration;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-resourcegraph;1.0.0-beta.3;1.0.0-beta.4
com.azure.resourcemanager:azure-resourcemanager-resourcegraph;1.0.0-beta.3;1.0.0
com.azure.resourcemanager:azure-resourcemanager-changeanalysis;1.0.0;1.1.0-beta.1
com.azure.resourcemanager:azure-resourcemanager-delegatednetwork;1.0.0-beta.1;1.0.0-beta.2
com.azure.resourcemanager:azure-resourcemanager-synapse;1.0.0-beta.6;1.0.0-beta.7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# Release History

## 1.0.0-beta.4 (Unreleased)
## 1.0.0 (2022-11-02)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
- Azure Resource Manager ResourceGraph client library for Java. This package contains Microsoft Azure SDK for ResourceGraph Management SDK. Azure Resource Graph API Reference. Package tag package-2021-03. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

## 1.0.0-beta.3 (2022-04-07)

Expand Down
25 changes: 14 additions & 11 deletions sdk/resourcegraph/azure-resourcemanager-resourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-resourcegraph</artifactId>
<version>1.0.0-beta.3</version>
<version>1.0.0</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand All @@ -41,19 +41,19 @@ Various documentation is available to help you get started

Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client.

[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation.
[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation.

### Authentication

By default, Azure Active Directory token authentication depends on correct configure of following environment variables.
By default, Azure Active Directory token authentication depends on correct configuration of the following environment variables.

- `AZURE_CLIENT_ID` for Azure client ID.
- `AZURE_TENANT_ID` for Azure tenant ID.
- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate.

In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.
In addition, Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

With above configuration, `azure` client can be authenticated by following code:
With above configuration, `azure` client can be authenticated using the following code:

```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
Expand Down Expand Up @@ -97,13 +97,13 @@ response = manager.resourceProviders().resources(queryRequest);

## Contributing

For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md).
For details on contributing to this repository, see the [contributing guide][cg].

1. Fork it
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
1. Create new Pull Request
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit <https://cla.microsoft.com>.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact <opencode@microsoft.com> with any additional questions or comments.

<!-- LINKS -->
[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS
Expand All @@ -114,3 +114,6 @@ For details on contributing to this repository, see the [contributing guide](htt
[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty
[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md
[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md
[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md
[coc]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
20 changes: 16 additions & 4 deletions sdk/resourcegraph/azure-resourcemanager-resourcegraph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-resourcegraph</artifactId>
<version>1.0.0-beta.4</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-resourcegraph;current} -->
<version>1.0.0</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-resourcegraph;current} -->
<packaging>jar</packaging>

<name>Microsoft Azure SDK for ResourceGraph Management</name>
Expand Down Expand Up @@ -51,16 +51,28 @@
<artifactId>azure-core-management</artifactId>
<version>1.8.1</version> <!-- {x-version-update;com.azure:azure-core-management;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.12.1</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.6.1</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.12.1</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.5.1</version> <!-- {x-version-update;org.mockito:mockito-core;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public ResourceGraphManager authenticate(TokenCredential credential, AzureProfil
.append("-")
.append("com.azure.resourcemanager.resourcegraph")
.append("/")
.append("1.0.0-beta.3");
.append("1.0.0");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder
.append(" (")
Expand Down Expand Up @@ -263,15 +263,23 @@ public ResourceGraphManager authenticate(TokenCredential credential, AzureProfil
}
}

/** @return Resource collection API of ResourceProviders. */
/**
* Gets the resource collection API of ResourceProviders.
*
* @return Resource collection API of ResourceProviders.
*/
public ResourceProviders resourceProviders() {
if (this.resourceProviders == null) {
this.resourceProviders = new ResourceProvidersImpl(clientObject.getResourceProviders(), this);
}
return resourceProviders;
}

/** @return Resource collection API of Operations. */
/**
* Gets the resource collection API of Operations.
*
* @return Resource collection API of Operations.
*/
public Operations operations() {
if (this.operations == null) {
this.operations = new OperationsImpl(clientObject.getOperations(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ public interface ResourceProvidersClient {
* Queries the resources managed by Azure Resource Manager for scopes specified in the request.
*
* @param query Request specifying query and its options.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return query result.
* @return query result along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
QueryResponseInner resources(QueryRequest query);
Response<QueryResponseInner> resourcesWithResponse(QueryRequest query, Context context);

/**
* Queries the resources managed by Azure Resource Manager for scopes specified in the request.
*
* @param query Request specifying query and its options.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return query result along with {@link Response}.
* @return query result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
Response<QueryResponseInner> resourcesWithResponse(QueryRequest query, Context context);
QueryResponseInner resources(QueryRequest query);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public final class OperationInner {
@JsonProperty(value = "origin")
private String origin;

/** Creates an instance of OperationInner class. */
public OperationInner() {
}

/**
* Get the name property: Operation name: {provider}/{resource}/{operation}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public final class QueryResponseInner {
private long totalRecords;

/*
* Number of records returned in the current response. In the case of
* paging, this is the number of records in the current page.
* Number of records returned in the current response. In the case of paging, this is the number of records in the
* current page.
*/
@JsonProperty(value = "count", required = true)
private long count;
Expand All @@ -34,9 +34,8 @@ public final class QueryResponseInner {
private ResultTruncated resultTruncated;

/*
* When present, the value can be passed to a subsequent query call
* (together with the same query and scopes used in the current request) to
* retrieve the next page of data.
* When present, the value can be passed to a subsequent query call (together with the same query and scopes used
* in the current request) to retrieve the next page of data.
*/
@JsonProperty(value = "$skipToken")
private String skipToken;
Expand All @@ -53,6 +52,10 @@ public final class QueryResponseInner {
@JsonProperty(value = "facets")
private List<Facet> facets;

/** Creates an instance of QueryResponseInner class. */
public QueryResponseInner() {
}

/**
* Get the totalRecords property: Number of total records matching the query.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,21 @@ public ResourceGraphClientBuilder serializerAdapter(SerializerAdapter serializer
* @return an instance of ResourceGraphClientImpl.
*/
public ResourceGraphClientImpl buildClient() {
if (pipeline == null) {
this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build();
}
if (endpoint == null) {
this.endpoint = "https://management.azure.com";
}
if (environment == null) {
this.environment = AzureEnvironment.AZURE;
}
if (pipeline == null) {
this.pipeline = new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build();
}
if (defaultPollInterval == null) {
this.defaultPollInterval = Duration.ofSeconds(30);
}
if (serializerAdapter == null) {
this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter();
}
String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com";
AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE;
HttpPipeline localPipeline =
(pipeline != null)
? pipeline
: new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build();
Duration localDefaultPollInterval =
(defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30);
SerializerAdapter localSerializerAdapter =
(serializerAdapter != null)
? serializerAdapter
: SerializerFactory.createDefaultManagementSerializerAdapter();
ResourceGraphClientImpl client =
new ResourceGraphClientImpl(pipeline, serializerAdapter, defaultPollInterval, environment, endpoint);
new ResourceGraphClientImpl(
localPipeline, localSerializerAdapter, localDefaultPollInterval, localEnvironment, localEndpoint);
return client;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.azure.core.management.polling.PollResult;
import com.azure.core.management.polling.PollerFactory;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.polling.AsyncPollResponse;
import com.azure.core.util.polling.LongRunningOperationStatus;
Expand All @@ -30,7 +31,6 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Map;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -161,10 +161,7 @@ public Context getContext() {
* @return the merged context.
*/
public Context mergeContext(Context context) {
for (Map.Entry<Object, Object> entry : this.getContext().getValues().entrySet()) {
context = context.addData(entry.getKey(), entry.getValue());
}
return context;
return CoreUtils.mergeContexts(this.getContext(), context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,43 +133,35 @@ private Mono<Response<QueryResponseInner>> resourcesWithResponseAsync(QueryReque
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<QueryResponseInner> resourcesAsync(QueryRequest query) {
return resourcesWithResponseAsync(query)
.flatMap(
(Response<QueryResponseInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
return resourcesWithResponseAsync(query).flatMap(res -> Mono.justOrEmpty(res.getValue()));
}

/**
* Queries the resources managed by Azure Resource Manager for scopes specified in the request.
*
* @param query Request specifying query and its options.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return query result.
* @return query result along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public QueryResponseInner resources(QueryRequest query) {
return resourcesAsync(query).block();
public Response<QueryResponseInner> resourcesWithResponse(QueryRequest query, Context context) {
return resourcesWithResponseAsync(query, context).block();
}

/**
* Queries the resources managed by Azure Resource Manager for scopes specified in the request.
*
* @param query Request specifying query and its options.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return query result along with {@link Response}.
* @return query result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueryResponseInner> resourcesWithResponse(QueryRequest query, Context context) {
return resourcesWithResponseAsync(query, context).block();
public QueryResponseInner resources(QueryRequest query) {
return resourcesWithResponse(query, Context.NONE).getValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ public ResourceProvidersImpl(
this.serviceManager = serviceManager;
}

public QueryResponse resources(QueryRequest query) {
QueryResponseInner inner = this.serviceClient().resources(query);
if (inner != null) {
return new QueryResponseImpl(inner, this.manager());
} else {
return null;
}
}

public Response<QueryResponse> resourcesWithResponse(QueryRequest query, Context context) {
Response<QueryResponseInner> inner = this.serviceClient().resourcesWithResponse(query, context);
if (inner != null) {
Expand All @@ -50,6 +41,15 @@ public Response<QueryResponse> resourcesWithResponse(QueryRequest query, Context
}
}

public QueryResponse resources(QueryRequest query) {
QueryResponseInner inner = this.serviceClient().resources(query);
if (inner != null) {
return new QueryResponseImpl(inner, this.manager());
} else {
return null;
}
}

private ResourceProvidersClient serviceClient() {
return this.innerClient;
}
Expand Down
Loading