1010import com .azure .core .http .HttpPipelineBuilder ;
1111import com .azure .core .http .HttpPipelinePosition ;
1212import com .azure .core .http .policy .AddDatePolicy ;
13+ import com .azure .core .http .policy .AddHeadersFromContextPolicy ;
1314import com .azure .core .http .policy .HttpLogOptions ;
1415import com .azure .core .http .policy .HttpLoggingPolicy ;
1516import com .azure .core .http .policy .HttpPipelinePolicy ;
1617import com .azure .core .http .policy .HttpPolicyProviders ;
1718import com .azure .core .http .policy .RequestIdPolicy ;
19+ import com .azure .core .http .policy .RetryOptions ;
1820import com .azure .core .http .policy .RetryPolicy ;
1921import com .azure .core .http .policy .UserAgentPolicy ;
2022import com .azure .core .management .http .policy .ArmChallengeAuthenticationPolicy ;
@@ -87,6 +89,19 @@ public static IotHubManager authenticate(TokenCredential credential, AzureProfil
8789 return configure ().authenticate (credential , profile );
8890 }
8991
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+
90105 /**
91106 * Gets a Configurable instance that can be used to create IotHubManager with optional configuration.
92107 *
@@ -98,13 +113,14 @@ public static Configurable configure() {
98113
99114 /** The Configurable allowing configurations to be set. */
100115 public static final class Configurable {
101- private final ClientLogger logger = new ClientLogger (Configurable .class );
116+ private static final ClientLogger LOGGER = new ClientLogger (Configurable .class );
102117
103118 private HttpClient httpClient ;
104119 private HttpLogOptions httpLogOptions ;
105120 private final List <HttpPipelinePolicy > policies = new ArrayList <>();
106121 private final List <String > scopes = new ArrayList <>();
107122 private RetryPolicy retryPolicy ;
123+ private RetryOptions retryOptions ;
108124 private Duration defaultPollInterval ;
109125
110126 private Configurable () {
@@ -165,16 +181,31 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
165181 return this ;
166182 }
167183
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+
168197 /**
169198 * Sets the default poll interval, used when service does not provide "Retry-After" header.
170199 *
171200 * @param defaultPollInterval the default poll interval.
172201 * @return the configurable object itself.
173202 */
174203 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." );
176206 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" ));
178209 }
179210 return this ;
180211 }
@@ -196,7 +227,7 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi
196227 .append ("-" )
197228 .append ("com.azure.resourcemanager.iothub" )
198229 .append ("/" )
199- .append ("1.2 .0-beta.1" );
230+ .append ("1.0 .0-beta.1" );
200231 if (!Configuration .getGlobalConfiguration ().get ("AZURE_TELEMETRY_DISABLED" , false )) {
201232 userAgentBuilder
202233 .append (" (" )
@@ -214,10 +245,15 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi
214245 scopes .add (profile .getEnvironment ().getManagementEndpoint () + "/.default" );
215246 }
216247 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+ }
218253 }
219254 List <HttpPipelinePolicy > policies = new ArrayList <>();
220255 policies .add (new UserAgentPolicy (userAgentBuilder .toString ()));
256+ policies .add (new AddHeadersFromContextPolicy ());
221257 policies .add (new RequestIdPolicy ());
222258 policies
223259 .addAll (
@@ -248,23 +284,35 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi
248284 }
249285 }
250286
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+ */
252292 public Operations operations () {
253293 if (this .operations == null ) {
254294 this .operations = new OperationsImpl (clientObject .getOperations (), this );
255295 }
256296 return operations ;
257297 }
258298
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+ */
260304 public IotHubResources iotHubResources () {
261305 if (this .iotHubResources == null ) {
262306 this .iotHubResources = new IotHubResourcesImpl (clientObject .getIotHubResources (), this );
263307 }
264308 return iotHubResources ;
265309 }
266310
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+ */
268316 public ResourceProviderCommons resourceProviderCommons () {
269317 if (this .resourceProviderCommons == null ) {
270318 this .resourceProviderCommons =
@@ -273,23 +321,35 @@ public ResourceProviderCommons resourceProviderCommons() {
273321 return resourceProviderCommons ;
274322 }
275323
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+ */
277329 public Certificates certificates () {
278330 if (this .certificates == null ) {
279331 this .certificates = new CertificatesImpl (clientObject .getCertificates (), this );
280332 }
281333 return certificates ;
282334 }
283335
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+ */
285341 public IotHubs iotHubs () {
286342 if (this .iotHubs == null ) {
287343 this .iotHubs = new IotHubsImpl (clientObject .getIotHubs (), this );
288344 }
289345 return iotHubs ;
290346 }
291347
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+ */
293353 public PrivateLinkResourcesOperations privateLinkResourcesOperations () {
294354 if (this .privateLinkResourcesOperations == null ) {
295355 this .privateLinkResourcesOperations =
@@ -298,7 +358,11 @@ public PrivateLinkResourcesOperations privateLinkResourcesOperations() {
298358 return privateLinkResourcesOperations ;
299359 }
300360
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+ */
302366 public PrivateEndpointConnections privateEndpointConnections () {
303367 if (this .privateEndpointConnections == null ) {
304368 this .privateEndpointConnections =
0 commit comments