Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release History

## 1.0.0-beta.3 (Unreleased)
## 1.0.0-beta.1 (2022-09-15)

- Azure Resource Manager ResourceHealth client library for Java. This package contains Microsoft Azure SDK for ResourceHealth Management SDK. The Resource Health Client. Package tag package-2020-05-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

### Features Added

Expand Down
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-resourcehealth</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.3</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpPipelinePosition;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
import com.azure.core.http.policy.RetryOptions;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy;
Expand Down Expand Up @@ -67,6 +69,19 @@ public static ResourceHealthManager authenticate(TokenCredential credential, Azu
return configure().authenticate(credential, profile);
}

/**
* Creates an instance of ResourceHealth service API entry point.
*
* @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
* @param profile the Azure profile for client.
* @return the ResourceHealth service API instance.
*/
public static ResourceHealthManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new ResourceHealthManager(httpPipeline, profile, null);
}

/**
* Gets a Configurable instance that can be used to create ResourceHealthManager with optional configuration.
*
Expand All @@ -85,6 +100,7 @@ public static final class Configurable {
private final List<HttpPipelinePolicy> policies = new ArrayList<>();
private final List<String> scopes = new ArrayList<>();
private RetryPolicy retryPolicy;
private RetryOptions retryOptions;
private Duration defaultPollInterval;

private Configurable() {
Expand Down Expand Up @@ -145,6 +161,19 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
return this;
}

/**
* Sets the retry options for the HTTP pipeline retry policy.
*
* <p>This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}.
*
* @param retryOptions the retry options for the HTTP pipeline retry policy.
* @return the configurable object itself.
*/
public Configurable withRetryOptions(RetryOptions retryOptions) {
this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null.");
return this;
}

/**
* Sets the default poll interval, used when service does not provide "Retry-After" header.
*
Expand Down Expand Up @@ -178,7 +207,7 @@ public ResourceHealthManager authenticate(TokenCredential credential, AzureProfi
.append("-")
.append("com.azure.resourcemanager.resourcehealth")
.append("/")
.append("1.0.0-beta.2");
.append("1.0.0-beta.1");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder
.append(" (")
Expand All @@ -196,10 +225,15 @@ public ResourceHealthManager authenticate(TokenCredential credential, AzureProfi
scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default");
}
if (retryPolicy == null) {
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
if (retryOptions != null) {
retryPolicy = new RetryPolicy(retryOptions);
} else {
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
}
}
List<HttpPipelinePolicy> policies = new ArrayList<>();
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
policies.add(new AddHeadersFromContextPolicy());
policies.add(new RequestIdPolicy());
policies
.addAll(
Expand Down Expand Up @@ -230,15 +264,23 @@ public ResourceHealthManager authenticate(TokenCredential credential, AzureProfi
}
}

/** @return Resource collection API of AvailabilityStatuses. */
/**
* Gets the resource collection API of AvailabilityStatuses.
*
* @return Resource collection API of AvailabilityStatuses.
*/
public AvailabilityStatuses availabilityStatuses() {
if (this.availabilityStatuses == null) {
this.availabilityStatuses = new AvailabilityStatusesImpl(clientObject.getAvailabilityStatuses(), this);
}
return availabilityStatuses;
}

/** @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 @@ -639,14 +639,7 @@ private Mono<Response<AvailabilityStatusInner>> getByResourceWithResponseAsync(
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<AvailabilityStatusInner> getByResourceAsync(String resourceUri, String filter, String expand) {
return getByResourceWithResponseAsync(resourceUri, filter, expand)
.flatMap(
(Response<AvailabilityStatusInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}

/**
Expand All @@ -667,14 +660,7 @@ private Mono<AvailabilityStatusInner> getByResourceAsync(String resourceUri) {
final String filter = null;
final String expand = null;
return getByResourceWithResponseAsync(resourceUri, filter, expand)
.flatMap(
(Response<AvailabilityStatusInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}

/**
Expand Down Expand Up @@ -933,7 +919,8 @@ public PagedIterable<AvailabilityStatusInner> list(
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param nextLink The URL to get the next list of items
* <p>The nextLink parameter.
* @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.
Expand Down Expand Up @@ -970,7 +957,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listBySubscriptionIdNextSin
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param nextLink The URL to get the next list of items
* <p>The nextLink parameter.
* @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.
Expand Down Expand Up @@ -1008,7 +996,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listBySubscriptionIdNextSin
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param nextLink The URL to get the next list of items
* <p>The nextLink parameter.
* @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.
Expand Down Expand Up @@ -1045,7 +1034,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listByResourceGroupNextSing
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param nextLink The URL to get the next list of items
* <p>The nextLink parameter.
* @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.
Expand Down Expand Up @@ -1083,7 +1073,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listByResourceGroupNextSing
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param nextLink The URL to get the next list of items
* <p>The nextLink parameter.
* @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.
Expand Down Expand Up @@ -1119,7 +1110,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listNextSinglePageAsync(Str
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param nextLink The URL to get the next list of items
* <p>The nextLink parameter.
* @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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.management.AzureEnvironment;
Expand All @@ -19,9 +18,8 @@
@ServiceClientBuilder(serviceClients = {MicrosoftResourceHealthImpl.class})
public final class MicrosoftResourceHealthBuilder {
/*
* Subscription credentials which uniquely identify Microsoft Azure
* subscription. The subscription ID forms part of the URI for every
* service call.
* Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of
* the URI for every service call.
*/
private String subscriptionId;

Expand Down Expand Up @@ -70,34 +68,34 @@ public MicrosoftResourceHealthBuilder environment(AzureEnvironment environment)
}

/*
* The default poll interval for long-running operation
* The HTTP pipeline to send requests through
*/
private Duration defaultPollInterval;
private HttpPipeline pipeline;

/**
* Sets The default poll interval for long-running operation.
* Sets The HTTP pipeline to send requests through.
*
* @param defaultPollInterval the defaultPollInterval value.
* @param pipeline the pipeline value.
* @return the MicrosoftResourceHealthBuilder.
*/
public MicrosoftResourceHealthBuilder defaultPollInterval(Duration defaultPollInterval) {
this.defaultPollInterval = defaultPollInterval;
public MicrosoftResourceHealthBuilder pipeline(HttpPipeline pipeline) {
this.pipeline = pipeline;
return this;
}

/*
* The HTTP pipeline to send requests through
* The default poll interval for long-running operation
*/
private HttpPipeline pipeline;
private Duration defaultPollInterval;

/**
* Sets The HTTP pipeline to send requests through.
* Sets The default poll interval for long-running operation.
*
* @param pipeline the pipeline value.
* @param defaultPollInterval the defaultPollInterval value.
* @return the MicrosoftResourceHealthBuilder.
*/
public MicrosoftResourceHealthBuilder pipeline(HttpPipeline pipeline) {
this.pipeline = pipeline;
public MicrosoftResourceHealthBuilder defaultPollInterval(Duration defaultPollInterval) {
this.defaultPollInterval = defaultPollInterval;
return this;
}

Expand All @@ -123,27 +121,26 @@ public MicrosoftResourceHealthBuilder serializerAdapter(SerializerAdapter serial
* @return an instance of MicrosoftResourceHealthImpl.
*/
public MicrosoftResourceHealthImpl buildClient() {
if (endpoint == null) {
this.endpoint = "https://management.azure.com";
}
if (environment == null) {
this.environment = AzureEnvironment.AZURE;
}
if (defaultPollInterval == null) {
this.defaultPollInterval = Duration.ofSeconds(30);
}
if (pipeline == null) {
this.pipeline =
new HttpPipelineBuilder()
.policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
.build();
}
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();
MicrosoftResourceHealthImpl client =
new MicrosoftResourceHealthImpl(
pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint);
localPipeline,
localSerializerAdapter,
localDefaultPollInterval,
localEnvironment,
subscriptionId,
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 @@ -181,10 +181,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 @@ -114,15 +114,7 @@ private Mono<Response<OperationListResultInner>> listWithResponseAsync(Context c
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<OperationListResultInner> listAsync() {
return listWithResponseAsync()
.flatMap(
(Response<OperationListResultInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
return listWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue()));
}

/**
Expand Down
Loading