Skip to content

Commit 19cec99

Browse files
author
SDKAuto
committed
CodeGen from PR 19956 in Azure/azure-rest-api-specs
Merge 183dbd42aef82973d3fc506db21bae8b44cdbbb7 into f70b7953f5d54889cc1825b37ad938342ca93a2e
1 parent 5de376c commit 19cec99

File tree

12 files changed

+162
-139
lines changed

12 files changed

+162
-139
lines changed

sdk/resourcehealth/azure-resourcemanager-resourcehealth/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Release History
22

3-
## 1.0.0-beta.3 (Unreleased)
3+
## 1.0.0-beta.1 (2022-09-15)
4+
5+
- 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).
46

57
### Features Added
68

sdk/resourcehealth/azure-resourcemanager-resourcehealth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Various documentation is available to help you get started
3232
<dependency>
3333
<groupId>com.azure.resourcemanager</groupId>
3434
<artifactId>azure-resourcemanager-resourcehealth</artifactId>
35-
<version>1.0.0-beta.2</version>
35+
<version>1.0.0-beta.3</version>
3636
</dependency>
3737
```
3838
[//]: # ({x-version-update-end})

sdk/resourcehealth/azure-resourcemanager-resourcehealth/src/main/java/com/azure/resourcemanager/resourcehealth/ResourceHealthManager.java

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
import com.azure.core.http.HttpPipelineBuilder;
1111
import com.azure.core.http.HttpPipelinePosition;
1212
import com.azure.core.http.policy.AddDatePolicy;
13+
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
1314
import com.azure.core.http.policy.HttpLogOptions;
1415
import com.azure.core.http.policy.HttpLoggingPolicy;
1516
import com.azure.core.http.policy.HttpPipelinePolicy;
1617
import com.azure.core.http.policy.HttpPolicyProviders;
1718
import com.azure.core.http.policy.RequestIdPolicy;
19+
import com.azure.core.http.policy.RetryOptions;
1820
import com.azure.core.http.policy.RetryPolicy;
1921
import com.azure.core.http.policy.UserAgentPolicy;
2022
import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy;
@@ -67,6 +69,19 @@ public static ResourceHealthManager authenticate(TokenCredential credential, Azu
6769
return configure().authenticate(credential, profile);
6870
}
6971

72+
/**
73+
* Creates an instance of ResourceHealth service API entry point.
74+
*
75+
* @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
76+
* @param profile the Azure profile for client.
77+
* @return the ResourceHealth service API instance.
78+
*/
79+
public static ResourceHealthManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
80+
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
81+
Objects.requireNonNull(profile, "'profile' cannot be null.");
82+
return new ResourceHealthManager(httpPipeline, profile, null);
83+
}
84+
7085
/**
7186
* Gets a Configurable instance that can be used to create ResourceHealthManager with optional configuration.
7287
*
@@ -85,6 +100,7 @@ public static final class Configurable {
85100
private final List<HttpPipelinePolicy> policies = new ArrayList<>();
86101
private final List<String> scopes = new ArrayList<>();
87102
private RetryPolicy retryPolicy;
103+
private RetryOptions retryOptions;
88104
private Duration defaultPollInterval;
89105

90106
private Configurable() {
@@ -145,6 +161,19 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
145161
return this;
146162
}
147163

164+
/**
165+
* Sets the retry options for the HTTP pipeline retry policy.
166+
*
167+
* <p>This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}.
168+
*
169+
* @param retryOptions the retry options for the HTTP pipeline retry policy.
170+
* @return the configurable object itself.
171+
*/
172+
public Configurable withRetryOptions(RetryOptions retryOptions) {
173+
this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null.");
174+
return this;
175+
}
176+
148177
/**
149178
* Sets the default poll interval, used when service does not provide "Retry-After" header.
150179
*
@@ -178,7 +207,7 @@ public ResourceHealthManager authenticate(TokenCredential credential, AzureProfi
178207
.append("-")
179208
.append("com.azure.resourcemanager.resourcehealth")
180209
.append("/")
181-
.append("1.0.0-beta.2");
210+
.append("1.0.0-beta.1");
182211
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
183212
userAgentBuilder
184213
.append(" (")
@@ -196,10 +225,15 @@ public ResourceHealthManager authenticate(TokenCredential credential, AzureProfi
196225
scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default");
197226
}
198227
if (retryPolicy == null) {
199-
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
228+
if (retryOptions != null) {
229+
retryPolicy = new RetryPolicy(retryOptions);
230+
} else {
231+
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
232+
}
200233
}
201234
List<HttpPipelinePolicy> policies = new ArrayList<>();
202235
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
236+
policies.add(new AddHeadersFromContextPolicy());
203237
policies.add(new RequestIdPolicy());
204238
policies
205239
.addAll(
@@ -230,15 +264,23 @@ public ResourceHealthManager authenticate(TokenCredential credential, AzureProfi
230264
}
231265
}
232266

233-
/** @return Resource collection API of AvailabilityStatuses. */
267+
/**
268+
* Gets the resource collection API of AvailabilityStatuses.
269+
*
270+
* @return Resource collection API of AvailabilityStatuses.
271+
*/
234272
public AvailabilityStatuses availabilityStatuses() {
235273
if (this.availabilityStatuses == null) {
236274
this.availabilityStatuses = new AvailabilityStatusesImpl(clientObject.getAvailabilityStatuses(), this);
237275
}
238276
return availabilityStatuses;
239277
}
240278

241-
/** @return Resource collection API of Operations. */
279+
/**
280+
* Gets the resource collection API of Operations.
281+
*
282+
* @return Resource collection API of Operations.
283+
*/
242284
public Operations operations() {
243285
if (this.operations == null) {
244286
this.operations = new OperationsImpl(clientObject.getOperations(), this);

sdk/resourcehealth/azure-resourcemanager-resourcehealth/src/main/java/com/azure/resourcemanager/resourcehealth/implementation/AvailabilityStatusesClientImpl.java

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,7 @@ private Mono<Response<AvailabilityStatusInner>> getByResourceWithResponseAsync(
639639
@ServiceMethod(returns = ReturnType.SINGLE)
640640
private Mono<AvailabilityStatusInner> getByResourceAsync(String resourceUri, String filter, String expand) {
641641
return getByResourceWithResponseAsync(resourceUri, filter, expand)
642-
.flatMap(
643-
(Response<AvailabilityStatusInner> res) -> {
644-
if (res.getValue() != null) {
645-
return Mono.just(res.getValue());
646-
} else {
647-
return Mono.empty();
648-
}
649-
});
642+
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
650643
}
651644

652645
/**
@@ -667,14 +660,7 @@ private Mono<AvailabilityStatusInner> getByResourceAsync(String resourceUri) {
667660
final String filter = null;
668661
final String expand = null;
669662
return getByResourceWithResponseAsync(resourceUri, filter, expand)
670-
.flatMap(
671-
(Response<AvailabilityStatusInner> res) -> {
672-
if (res.getValue() != null) {
673-
return Mono.just(res.getValue());
674-
} else {
675-
return Mono.empty();
676-
}
677-
});
663+
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
678664
}
679665

680666
/**
@@ -933,7 +919,8 @@ public PagedIterable<AvailabilityStatusInner> list(
933919
/**
934920
* Get the next page of items.
935921
*
936-
* @param nextLink The nextLink parameter.
922+
* @param nextLink The URL to get the next list of items
923+
* <p>The nextLink parameter.
937924
* @throws IllegalArgumentException thrown if parameters fail the validation.
938925
* @throws ManagementException thrown if the request is rejected by server.
939926
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
@@ -970,7 +957,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listBySubscriptionIdNextSin
970957
/**
971958
* Get the next page of items.
972959
*
973-
* @param nextLink The nextLink parameter.
960+
* @param nextLink The URL to get the next list of items
961+
* <p>The nextLink parameter.
974962
* @param context The context to associate with this operation.
975963
* @throws IllegalArgumentException thrown if parameters fail the validation.
976964
* @throws ManagementException thrown if the request is rejected by server.
@@ -1008,7 +996,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listBySubscriptionIdNextSin
1008996
/**
1009997
* Get the next page of items.
1010998
*
1011-
* @param nextLink The nextLink parameter.
999+
* @param nextLink The URL to get the next list of items
1000+
* <p>The nextLink parameter.
10121001
* @throws IllegalArgumentException thrown if parameters fail the validation.
10131002
* @throws ManagementException thrown if the request is rejected by server.
10141003
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
@@ -1045,7 +1034,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listByResourceGroupNextSing
10451034
/**
10461035
* Get the next page of items.
10471036
*
1048-
* @param nextLink The nextLink parameter.
1037+
* @param nextLink The URL to get the next list of items
1038+
* <p>The nextLink parameter.
10491039
* @param context The context to associate with this operation.
10501040
* @throws IllegalArgumentException thrown if parameters fail the validation.
10511041
* @throws ManagementException thrown if the request is rejected by server.
@@ -1083,7 +1073,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listByResourceGroupNextSing
10831073
/**
10841074
* Get the next page of items.
10851075
*
1086-
* @param nextLink The nextLink parameter.
1076+
* @param nextLink The URL to get the next list of items
1077+
* <p>The nextLink parameter.
10871078
* @throws IllegalArgumentException thrown if parameters fail the validation.
10881079
* @throws ManagementException thrown if the request is rejected by server.
10891080
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
@@ -1119,7 +1110,8 @@ private Mono<PagedResponse<AvailabilityStatusInner>> listNextSinglePageAsync(Str
11191110
/**
11201111
* Get the next page of items.
11211112
*
1122-
* @param nextLink The nextLink parameter.
1113+
* @param nextLink The URL to get the next list of items
1114+
* <p>The nextLink parameter.
11231115
* @param context The context to associate with this operation.
11241116
* @throws IllegalArgumentException thrown if parameters fail the validation.
11251117
* @throws ManagementException thrown if the request is rejected by server.

sdk/resourcehealth/azure-resourcemanager-resourcehealth/src/main/java/com/azure/resourcemanager/resourcehealth/implementation/MicrosoftResourceHealthBuilder.java

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.azure.core.annotation.ServiceClientBuilder;
88
import com.azure.core.http.HttpPipeline;
99
import com.azure.core.http.HttpPipelineBuilder;
10-
import com.azure.core.http.policy.CookiePolicy;
1110
import com.azure.core.http.policy.RetryPolicy;
1211
import com.azure.core.http.policy.UserAgentPolicy;
1312
import com.azure.core.management.AzureEnvironment;
@@ -19,9 +18,8 @@
1918
@ServiceClientBuilder(serviceClients = {MicrosoftResourceHealthImpl.class})
2019
public final class MicrosoftResourceHealthBuilder {
2120
/*
22-
* Subscription credentials which uniquely identify Microsoft Azure
23-
* subscription. The subscription ID forms part of the URI for every
24-
* service call.
21+
* Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of
22+
* the URI for every service call.
2523
*/
2624
private String subscriptionId;
2725

@@ -70,34 +68,34 @@ public MicrosoftResourceHealthBuilder environment(AzureEnvironment environment)
7068
}
7169

7270
/*
73-
* The default poll interval for long-running operation
71+
* The HTTP pipeline to send requests through
7472
*/
75-
private Duration defaultPollInterval;
73+
private HttpPipeline pipeline;
7674

7775
/**
78-
* Sets The default poll interval for long-running operation.
76+
* Sets The HTTP pipeline to send requests through.
7977
*
80-
* @param defaultPollInterval the defaultPollInterval value.
78+
* @param pipeline the pipeline value.
8179
* @return the MicrosoftResourceHealthBuilder.
8280
*/
83-
public MicrosoftResourceHealthBuilder defaultPollInterval(Duration defaultPollInterval) {
84-
this.defaultPollInterval = defaultPollInterval;
81+
public MicrosoftResourceHealthBuilder pipeline(HttpPipeline pipeline) {
82+
this.pipeline = pipeline;
8583
return this;
8684
}
8785

8886
/*
89-
* The HTTP pipeline to send requests through
87+
* The default poll interval for long-running operation
9088
*/
91-
private HttpPipeline pipeline;
89+
private Duration defaultPollInterval;
9290

9391
/**
94-
* Sets The HTTP pipeline to send requests through.
92+
* Sets The default poll interval for long-running operation.
9593
*
96-
* @param pipeline the pipeline value.
94+
* @param defaultPollInterval the defaultPollInterval value.
9795
* @return the MicrosoftResourceHealthBuilder.
9896
*/
99-
public MicrosoftResourceHealthBuilder pipeline(HttpPipeline pipeline) {
100-
this.pipeline = pipeline;
97+
public MicrosoftResourceHealthBuilder defaultPollInterval(Duration defaultPollInterval) {
98+
this.defaultPollInterval = defaultPollInterval;
10199
return this;
102100
}
103101

@@ -123,27 +121,26 @@ public MicrosoftResourceHealthBuilder serializerAdapter(SerializerAdapter serial
123121
* @return an instance of MicrosoftResourceHealthImpl.
124122
*/
125123
public MicrosoftResourceHealthImpl buildClient() {
126-
if (endpoint == null) {
127-
this.endpoint = "https://management.azure.com";
128-
}
129-
if (environment == null) {
130-
this.environment = AzureEnvironment.AZURE;
131-
}
132-
if (defaultPollInterval == null) {
133-
this.defaultPollInterval = Duration.ofSeconds(30);
134-
}
135-
if (pipeline == null) {
136-
this.pipeline =
137-
new HttpPipelineBuilder()
138-
.policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
139-
.build();
140-
}
141-
if (serializerAdapter == null) {
142-
this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter();
143-
}
124+
String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com";
125+
AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE;
126+
HttpPipeline localPipeline =
127+
(pipeline != null)
128+
? pipeline
129+
: new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build();
130+
Duration localDefaultPollInterval =
131+
(defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30);
132+
SerializerAdapter localSerializerAdapter =
133+
(serializerAdapter != null)
134+
? serializerAdapter
135+
: SerializerFactory.createDefaultManagementSerializerAdapter();
144136
MicrosoftResourceHealthImpl client =
145137
new MicrosoftResourceHealthImpl(
146-
pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint);
138+
localPipeline,
139+
localSerializerAdapter,
140+
localDefaultPollInterval,
141+
localEnvironment,
142+
subscriptionId,
143+
localEndpoint);
147144
return client;
148145
}
149146
}

sdk/resourcehealth/azure-resourcemanager-resourcehealth/src/main/java/com/azure/resourcemanager/resourcehealth/implementation/MicrosoftResourceHealthImpl.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.azure.core.management.polling.PollResult;
1616
import com.azure.core.management.polling.PollerFactory;
1717
import com.azure.core.util.Context;
18+
import com.azure.core.util.CoreUtils;
1819
import com.azure.core.util.logging.ClientLogger;
1920
import com.azure.core.util.polling.AsyncPollResponse;
2021
import com.azure.core.util.polling.LongRunningOperationStatus;
@@ -30,7 +31,6 @@
3031
import java.nio.charset.Charset;
3132
import java.nio.charset.StandardCharsets;
3233
import java.time.Duration;
33-
import java.util.Map;
3434
import reactor.core.publisher.Flux;
3535
import reactor.core.publisher.Mono;
3636

@@ -181,10 +181,7 @@ public Context getContext() {
181181
* @return the merged context.
182182
*/
183183
public Context mergeContext(Context context) {
184-
for (Map.Entry<Object, Object> entry : this.getContext().getValues().entrySet()) {
185-
context = context.addData(entry.getKey(), entry.getValue());
186-
}
187-
return context;
184+
return CoreUtils.mergeContexts(this.getContext(), context);
188185
}
189186

190187
/**

sdk/resourcehealth/azure-resourcemanager-resourcehealth/src/main/java/com/azure/resourcemanager/resourcehealth/implementation/OperationsClientImpl.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,7 @@ private Mono<Response<OperationListResultInner>> listWithResponseAsync(Context c
114114
*/
115115
@ServiceMethod(returns = ReturnType.SINGLE)
116116
private Mono<OperationListResultInner> listAsync() {
117-
return listWithResponseAsync()
118-
.flatMap(
119-
(Response<OperationListResultInner> res) -> {
120-
if (res.getValue() != null) {
121-
return Mono.just(res.getValue());
122-
} else {
123-
return Mono.empty();
124-
}
125-
});
117+
return listWithResponseAsync().flatMap(res -> Mono.justOrEmpty(res.getValue()));
126118
}
127119

128120
/**

0 commit comments

Comments
 (0)