Skip to content

Commit

Permalink
CodeGen from PR 19956 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 27b1a263b0032a4010a9ae0cb09a71733af0e351 into 402c7fb924c5c0a30650d1c11338d4d516585933
  • Loading branch information
SDKAuto committed Jul 26, 2022
1 parent 18022bf commit 0d0befb
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 88 deletions.
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-07-26)

- 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
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 Down Expand Up @@ -70,34 +69,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 Down Expand Up @@ -129,15 +128,12 @@ public MicrosoftResourceHealthImpl buildClient() {
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 (pipeline == null) {
this.pipeline =
new HttpPipelineBuilder()
.policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
.build();
}
if (serializerAdapter == null) {
this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter();
}
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public static AvailabilityStateValues fromString(String name) {
return fromString(name, AvailabilityStateValues.class);
}

/** @return known AvailabilityStateValues values. */
/**
* Gets known AvailabilityStateValues values.
*
* @return known AvailabilityStateValues values.
*/
public static Collection<AvailabilityStateValues> values() {
return values(AvailabilityStateValues.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public final class AvailabilityStatusProperties {
/*
* Timestamp for when last change in health status occurred.
*/
@JsonProperty(value = "occurredTime")
private OffsetDateTime occurredTime;
@JsonProperty(value = "occuredTime")
private OffsetDateTime occuredTime;

/*
* Chronicity of the availability transition.
Expand Down Expand Up @@ -364,22 +364,22 @@ public AvailabilityStatusProperties withResolutionEta(OffsetDateTime resolutionE
}

/**
* Get the occurredTime property: Timestamp for when last change in health status occurred.
* Get the occuredTime property: Timestamp for when last change in health status occurred.
*
* @return the occurredTime value.
* @return the occuredTime value.
*/
public OffsetDateTime occurredTime() {
return this.occurredTime;
public OffsetDateTime occuredTime() {
return this.occuredTime;
}

/**
* Set the occurredTime property: Timestamp for when last change in health status occurred.
* Set the occuredTime property: Timestamp for when last change in health status occurred.
*
* @param occurredTime the occurredTime value to set.
* @param occuredTime the occuredTime value to set.
* @return the AvailabilityStatusProperties object itself.
*/
public AvailabilityStatusProperties withOccurredTime(OffsetDateTime occurredTime) {
this.occurredTime = occurredTime;
public AvailabilityStatusProperties withOccuredTime(OffsetDateTime occuredTime) {
this.occuredTime = occuredTime;
return this;
}

Expand Down
Loading

0 comments on commit 0d0befb

Please sign in to comment.