10
10
import com .azure .core .http .HttpPipelineBuilder ;
11
11
import com .azure .core .http .HttpPipelinePosition ;
12
12
import com .azure .core .http .policy .AddDatePolicy ;
13
+ import com .azure .core .http .policy .AddHeadersFromContextPolicy ;
13
14
import com .azure .core .http .policy .HttpLogOptions ;
14
15
import com .azure .core .http .policy .HttpLoggingPolicy ;
15
16
import com .azure .core .http .policy .HttpPipelinePolicy ;
16
17
import com .azure .core .http .policy .HttpPolicyProviders ;
17
18
import com .azure .core .http .policy .RequestIdPolicy ;
19
+ import com .azure .core .http .policy .RetryOptions ;
18
20
import com .azure .core .http .policy .RetryPolicy ;
19
21
import com .azure .core .http .policy .UserAgentPolicy ;
20
22
import com .azure .core .management .http .policy .ArmChallengeAuthenticationPolicy ;
@@ -87,6 +89,19 @@ public static IotHubManager authenticate(TokenCredential credential, AzureProfil
87
89
return configure ().authenticate (credential , profile );
88
90
}
89
91
92
+ /**
93
+ * Creates an instance of IotHub service API entry point.
94
+ *
95
+ * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
96
+ * @param profile the Azure profile for client.
97
+ * @return the IotHub service API instance.
98
+ */
99
+ public static IotHubManager authenticate (HttpPipeline httpPipeline , AzureProfile profile ) {
100
+ Objects .requireNonNull (httpPipeline , "'httpPipeline' cannot be null." );
101
+ Objects .requireNonNull (profile , "'profile' cannot be null." );
102
+ return new IotHubManager (httpPipeline , profile , null );
103
+ }
104
+
90
105
/**
91
106
* Gets a Configurable instance that can be used to create IotHubManager with optional configuration.
92
107
*
@@ -98,13 +113,14 @@ public static Configurable configure() {
98
113
99
114
/** The Configurable allowing configurations to be set. */
100
115
public static final class Configurable {
101
- private final ClientLogger logger = new ClientLogger (Configurable .class );
116
+ private static final ClientLogger LOGGER = new ClientLogger (Configurable .class );
102
117
103
118
private HttpClient httpClient ;
104
119
private HttpLogOptions httpLogOptions ;
105
120
private final List <HttpPipelinePolicy > policies = new ArrayList <>();
106
121
private final List <String > scopes = new ArrayList <>();
107
122
private RetryPolicy retryPolicy ;
123
+ private RetryOptions retryOptions ;
108
124
private Duration defaultPollInterval ;
109
125
110
126
private Configurable () {
@@ -165,16 +181,31 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
165
181
return this ;
166
182
}
167
183
184
+ /**
185
+ * Sets the retry options for the HTTP pipeline retry policy.
186
+ *
187
+ * <p>This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}.
188
+ *
189
+ * @param retryOptions the retry options for the HTTP pipeline retry policy.
190
+ * @return the configurable object itself.
191
+ */
192
+ public Configurable withRetryOptions (RetryOptions retryOptions ) {
193
+ this .retryOptions = Objects .requireNonNull (retryOptions , "'retryOptions' cannot be null." );
194
+ return this ;
195
+ }
196
+
168
197
/**
169
198
* Sets the default poll interval, used when service does not provide "Retry-After" header.
170
199
*
171
200
* @param defaultPollInterval the default poll interval.
172
201
* @return the configurable object itself.
173
202
*/
174
203
public Configurable withDefaultPollInterval (Duration defaultPollInterval ) {
175
- this .defaultPollInterval = Objects .requireNonNull (defaultPollInterval , "'retryPolicy' cannot be null." );
204
+ this .defaultPollInterval =
205
+ Objects .requireNonNull (defaultPollInterval , "'defaultPollInterval' cannot be null." );
176
206
if (this .defaultPollInterval .isNegative ()) {
177
- throw logger .logExceptionAsError (new IllegalArgumentException ("'httpPipeline' cannot be negative" ));
207
+ throw LOGGER
208
+ .logExceptionAsError (new IllegalArgumentException ("'defaultPollInterval' cannot be negative" ));
178
209
}
179
210
return this ;
180
211
}
@@ -196,7 +227,7 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi
196
227
.append ("-" )
197
228
.append ("com.azure.resourcemanager.iothub" )
198
229
.append ("/" )
199
- .append ("1.2 .0-beta.1" );
230
+ .append ("1.0 .0-beta.1" );
200
231
if (!Configuration .getGlobalConfiguration ().get ("AZURE_TELEMETRY_DISABLED" , false )) {
201
232
userAgentBuilder
202
233
.append (" (" )
@@ -214,10 +245,15 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi
214
245
scopes .add (profile .getEnvironment ().getManagementEndpoint () + "/.default" );
215
246
}
216
247
if (retryPolicy == null ) {
217
- retryPolicy = new RetryPolicy ("Retry-After" , ChronoUnit .SECONDS );
248
+ if (retryOptions != null ) {
249
+ retryPolicy = new RetryPolicy (retryOptions );
250
+ } else {
251
+ retryPolicy = new RetryPolicy ("Retry-After" , ChronoUnit .SECONDS );
252
+ }
218
253
}
219
254
List <HttpPipelinePolicy > policies = new ArrayList <>();
220
255
policies .add (new UserAgentPolicy (userAgentBuilder .toString ()));
256
+ policies .add (new AddHeadersFromContextPolicy ());
221
257
policies .add (new RequestIdPolicy ());
222
258
policies
223
259
.addAll (
@@ -248,23 +284,35 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi
248
284
}
249
285
}
250
286
251
- /** @return Resource collection API of Operations. */
287
+ /**
288
+ * Gets the resource collection API of Operations.
289
+ *
290
+ * @return Resource collection API of Operations.
291
+ */
252
292
public Operations operations () {
253
293
if (this .operations == null ) {
254
294
this .operations = new OperationsImpl (clientObject .getOperations (), this );
255
295
}
256
296
return operations ;
257
297
}
258
298
259
- /** @return Resource collection API of IotHubResources. */
299
+ /**
300
+ * Gets the resource collection API of IotHubResources. It manages IotHubDescription, EventHubConsumerGroupInfo.
301
+ *
302
+ * @return Resource collection API of IotHubResources.
303
+ */
260
304
public IotHubResources iotHubResources () {
261
305
if (this .iotHubResources == null ) {
262
306
this .iotHubResources = new IotHubResourcesImpl (clientObject .getIotHubResources (), this );
263
307
}
264
308
return iotHubResources ;
265
309
}
266
310
267
- /** @return Resource collection API of ResourceProviderCommons. */
311
+ /**
312
+ * Gets the resource collection API of ResourceProviderCommons.
313
+ *
314
+ * @return Resource collection API of ResourceProviderCommons.
315
+ */
268
316
public ResourceProviderCommons resourceProviderCommons () {
269
317
if (this .resourceProviderCommons == null ) {
270
318
this .resourceProviderCommons =
@@ -273,23 +321,35 @@ public ResourceProviderCommons resourceProviderCommons() {
273
321
return resourceProviderCommons ;
274
322
}
275
323
276
- /** @return Resource collection API of Certificates. */
324
+ /**
325
+ * Gets the resource collection API of Certificates. It manages CertificateDescription.
326
+ *
327
+ * @return Resource collection API of Certificates.
328
+ */
277
329
public Certificates certificates () {
278
330
if (this .certificates == null ) {
279
331
this .certificates = new CertificatesImpl (clientObject .getCertificates (), this );
280
332
}
281
333
return certificates ;
282
334
}
283
335
284
- /** @return Resource collection API of IotHubs. */
336
+ /**
337
+ * Gets the resource collection API of IotHubs.
338
+ *
339
+ * @return Resource collection API of IotHubs.
340
+ */
285
341
public IotHubs iotHubs () {
286
342
if (this .iotHubs == null ) {
287
343
this .iotHubs = new IotHubsImpl (clientObject .getIotHubs (), this );
288
344
}
289
345
return iotHubs ;
290
346
}
291
347
292
- /** @return Resource collection API of PrivateLinkResourcesOperations. */
348
+ /**
349
+ * Gets the resource collection API of PrivateLinkResourcesOperations.
350
+ *
351
+ * @return Resource collection API of PrivateLinkResourcesOperations.
352
+ */
293
353
public PrivateLinkResourcesOperations privateLinkResourcesOperations () {
294
354
if (this .privateLinkResourcesOperations == null ) {
295
355
this .privateLinkResourcesOperations =
@@ -298,7 +358,11 @@ public PrivateLinkResourcesOperations privateLinkResourcesOperations() {
298
358
return privateLinkResourcesOperations ;
299
359
}
300
360
301
- /** @return Resource collection API of PrivateEndpointConnections. */
361
+ /**
362
+ * Gets the resource collection API of PrivateEndpointConnections.
363
+ *
364
+ * @return Resource collection API of PrivateEndpointConnections.
365
+ */
302
366
public PrivateEndpointConnections privateEndpointConnections () {
303
367
if (this .privateEndpointConnections == null ) {
304
368
this .privateEndpointConnections =
0 commit comments