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 ;
3335import com .azure .resourcemanager .dataprotection .implementation .ExportJobsOperationResultsImpl ;
3436import com .azure .resourcemanager .dataprotection .implementation .JobsImpl ;
3537import com .azure .resourcemanager .dataprotection .implementation .OperationResultsImpl ;
38+ import com .azure .resourcemanager .dataprotection .implementation .OperationStatusBackupVaultContextsImpl ;
3639import com .azure .resourcemanager .dataprotection .implementation .OperationStatusImpl ;
40+ import com .azure .resourcemanager .dataprotection .implementation .OperationStatusResourceGroupContextsImpl ;
3741import com .azure .resourcemanager .dataprotection .implementation .RecoveryPointsImpl ;
3842import com .azure .resourcemanager .dataprotection .implementation .ResourceGuardsImpl ;
3943import com .azure .resourcemanager .dataprotection .implementation .RestorableTimeRangesImpl ;
4852import com .azure .resourcemanager .dataprotection .models .Jobs ;
4953import com .azure .resourcemanager .dataprotection .models .OperationResults ;
5054import com .azure .resourcemanager .dataprotection .models .OperationStatus ;
55+ import com .azure .resourcemanager .dataprotection .models .OperationStatusBackupVaultContexts ;
56+ import com .azure .resourcemanager .dataprotection .models .OperationStatusResourceGroupContexts ;
5157import com .azure .resourcemanager .dataprotection .models .RecoveryPoints ;
5258import com .azure .resourcemanager .dataprotection .models .ResourceGuards ;
5359import com .azure .resourcemanager .dataprotection .models .RestorableTimeRanges ;
@@ -66,6 +72,10 @@ public final class DataProtectionManager {
6672
6773 private OperationStatus operationStatus ;
6874
75+ private OperationStatusBackupVaultContexts operationStatusBackupVaultContexts ;
76+
77+ private OperationStatusResourceGroupContexts operationStatusResourceGroupContexts ;
78+
6979 private BackupVaultOperationResults backupVaultOperationResults ;
7080
7181 private DataProtections dataProtections ;
@@ -115,6 +125,19 @@ public static DataProtectionManager authenticate(TokenCredential credential, Azu
115125 return configure ().authenticate (credential , profile );
116126 }
117127
128+ /**
129+ * Creates an instance of DataProtection service API entry point.
130+ *
131+ * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
132+ * @param profile the Azure profile for client.
133+ * @return the DataProtection service API instance.
134+ */
135+ public static DataProtectionManager authenticate (HttpPipeline httpPipeline , AzureProfile profile ) {
136+ Objects .requireNonNull (httpPipeline , "'httpPipeline' cannot be null." );
137+ Objects .requireNonNull (profile , "'profile' cannot be null." );
138+ return new DataProtectionManager (httpPipeline , profile , null );
139+ }
140+
118141 /**
119142 * Gets a Configurable instance that can be used to create DataProtectionManager with optional configuration.
120143 *
@@ -126,13 +149,14 @@ public static Configurable configure() {
126149
127150 /** The Configurable allowing configurations to be set. */
128151 public static final class Configurable {
129- private final ClientLogger logger = new ClientLogger (Configurable .class );
152+ private static final ClientLogger LOGGER = new ClientLogger (Configurable .class );
130153
131154 private HttpClient httpClient ;
132155 private HttpLogOptions httpLogOptions ;
133156 private final List <HttpPipelinePolicy > policies = new ArrayList <>();
134157 private final List <String > scopes = new ArrayList <>();
135158 private RetryPolicy retryPolicy ;
159+ private RetryOptions retryOptions ;
136160 private Duration defaultPollInterval ;
137161
138162 private Configurable () {
@@ -193,16 +217,31 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
193217 return this ;
194218 }
195219
220+ /**
221+ * Sets the retry options for the HTTP pipeline retry policy.
222+ *
223+ * <p>This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}.
224+ *
225+ * @param retryOptions the retry options for the HTTP pipeline retry policy.
226+ * @return the configurable object itself.
227+ */
228+ public Configurable withRetryOptions (RetryOptions retryOptions ) {
229+ this .retryOptions = Objects .requireNonNull (retryOptions , "'retryOptions' cannot be null." );
230+ return this ;
231+ }
232+
196233 /**
197234 * Sets the default poll interval, used when service does not provide "Retry-After" header.
198235 *
199236 * @param defaultPollInterval the default poll interval.
200237 * @return the configurable object itself.
201238 */
202239 public Configurable withDefaultPollInterval (Duration defaultPollInterval ) {
203- this .defaultPollInterval = Objects .requireNonNull (defaultPollInterval , "'retryPolicy' cannot be null." );
240+ this .defaultPollInterval =
241+ Objects .requireNonNull (defaultPollInterval , "'defaultPollInterval' cannot be null." );
204242 if (this .defaultPollInterval .isNegative ()) {
205- throw logger .logExceptionAsError (new IllegalArgumentException ("'httpPipeline' cannot be negative" ));
243+ throw LOGGER
244+ .logExceptionAsError (new IllegalArgumentException ("'defaultPollInterval' cannot be negative" ));
206245 }
207246 return this ;
208247 }
@@ -242,10 +281,15 @@ public DataProtectionManager authenticate(TokenCredential credential, AzureProfi
242281 scopes .add (profile .getEnvironment ().getManagementEndpoint () + "/.default" );
243282 }
244283 if (retryPolicy == null ) {
245- retryPolicy = new RetryPolicy ("Retry-After" , ChronoUnit .SECONDS );
284+ if (retryOptions != null ) {
285+ retryPolicy = new RetryPolicy (retryOptions );
286+ } else {
287+ retryPolicy = new RetryPolicy ("Retry-After" , ChronoUnit .SECONDS );
288+ }
246289 }
247290 List <HttpPipelinePolicy > policies = new ArrayList <>();
248291 policies .add (new UserAgentPolicy (userAgentBuilder .toString ()));
292+ policies .add (new AddHeadersFromContextPolicy ());
249293 policies .add (new RequestIdPolicy ());
250294 policies
251295 .addAll (
@@ -276,31 +320,74 @@ public DataProtectionManager authenticate(TokenCredential credential, AzureProfi
276320 }
277321 }
278322
279- /** @return Resource collection API of BackupVaults. */
323+ /**
324+ * Gets the resource collection API of BackupVaults. It manages BackupVaultResource.
325+ *
326+ * @return Resource collection API of BackupVaults.
327+ */
280328 public BackupVaults backupVaults () {
281329 if (this .backupVaults == null ) {
282330 this .backupVaults = new BackupVaultsImpl (clientObject .getBackupVaults (), this );
283331 }
284332 return backupVaults ;
285333 }
286334
287- /** @return Resource collection API of OperationResults. */
335+ /**
336+ * Gets the resource collection API of OperationResults.
337+ *
338+ * @return Resource collection API of OperationResults.
339+ */
288340 public OperationResults operationResults () {
289341 if (this .operationResults == null ) {
290342 this .operationResults = new OperationResultsImpl (clientObject .getOperationResults (), this );
291343 }
292344 return operationResults ;
293345 }
294346
295- /** @return Resource collection API of OperationStatus. */
347+ /**
348+ * Gets the resource collection API of OperationStatus.
349+ *
350+ * @return Resource collection API of OperationStatus.
351+ */
296352 public OperationStatus operationStatus () {
297353 if (this .operationStatus == null ) {
298354 this .operationStatus = new OperationStatusImpl (clientObject .getOperationStatus (), this );
299355 }
300356 return operationStatus ;
301357 }
302358
303- /** @return Resource collection API of BackupVaultOperationResults. */
359+ /**
360+ * Gets the resource collection API of OperationStatusBackupVaultContexts.
361+ *
362+ * @return Resource collection API of OperationStatusBackupVaultContexts.
363+ */
364+ public OperationStatusBackupVaultContexts operationStatusBackupVaultContexts () {
365+ if (this .operationStatusBackupVaultContexts == null ) {
366+ this .operationStatusBackupVaultContexts =
367+ new OperationStatusBackupVaultContextsImpl (clientObject .getOperationStatusBackupVaultContexts (), this );
368+ }
369+ return operationStatusBackupVaultContexts ;
370+ }
371+
372+ /**
373+ * Gets the resource collection API of OperationStatusResourceGroupContexts.
374+ *
375+ * @return Resource collection API of OperationStatusResourceGroupContexts.
376+ */
377+ public OperationStatusResourceGroupContexts operationStatusResourceGroupContexts () {
378+ if (this .operationStatusResourceGroupContexts == null ) {
379+ this .operationStatusResourceGroupContexts =
380+ new OperationStatusResourceGroupContextsImpl (
381+ clientObject .getOperationStatusResourceGroupContexts (), this );
382+ }
383+ return operationStatusResourceGroupContexts ;
384+ }
385+
386+ /**
387+ * Gets the resource collection API of BackupVaultOperationResults.
388+ *
389+ * @return Resource collection API of BackupVaultOperationResults.
390+ */
304391 public BackupVaultOperationResults backupVaultOperationResults () {
305392 if (this .backupVaultOperationResults == null ) {
306393 this .backupVaultOperationResults =
@@ -309,15 +396,23 @@ public BackupVaultOperationResults backupVaultOperationResults() {
309396 return backupVaultOperationResults ;
310397 }
311398
312- /** @return Resource collection API of DataProtections. */
399+ /**
400+ * Gets the resource collection API of DataProtections.
401+ *
402+ * @return Resource collection API of DataProtections.
403+ */
313404 public DataProtections dataProtections () {
314405 if (this .dataProtections == null ) {
315406 this .dataProtections = new DataProtectionsImpl (clientObject .getDataProtections (), this );
316407 }
317408 return dataProtections ;
318409 }
319410
320- /** @return Resource collection API of DataProtectionOperations. */
411+ /**
412+ * Gets the resource collection API of DataProtectionOperations.
413+ *
414+ * @return Resource collection API of DataProtectionOperations.
415+ */
321416 public DataProtectionOperations dataProtectionOperations () {
322417 if (this .dataProtectionOperations == null ) {
323418 this .dataProtectionOperations =
@@ -326,55 +421,83 @@ public DataProtectionOperations dataProtectionOperations() {
326421 return dataProtectionOperations ;
327422 }
328423
329- /** @return Resource collection API of BackupPolicies. */
424+ /**
425+ * Gets the resource collection API of BackupPolicies. It manages BaseBackupPolicyResource.
426+ *
427+ * @return Resource collection API of BackupPolicies.
428+ */
330429 public BackupPolicies backupPolicies () {
331430 if (this .backupPolicies == null ) {
332431 this .backupPolicies = new BackupPoliciesImpl (clientObject .getBackupPolicies (), this );
333432 }
334433 return backupPolicies ;
335434 }
336435
337- /** @return Resource collection API of BackupInstances. */
436+ /**
437+ * Gets the resource collection API of BackupInstances. It manages BackupInstanceResource.
438+ *
439+ * @return Resource collection API of BackupInstances.
440+ */
338441 public BackupInstances backupInstances () {
339442 if (this .backupInstances == null ) {
340443 this .backupInstances = new BackupInstancesImpl (clientObject .getBackupInstances (), this );
341444 }
342445 return backupInstances ;
343446 }
344447
345- /** @return Resource collection API of RecoveryPoints. */
448+ /**
449+ * Gets the resource collection API of RecoveryPoints.
450+ *
451+ * @return Resource collection API of RecoveryPoints.
452+ */
346453 public RecoveryPoints recoveryPoints () {
347454 if (this .recoveryPoints == null ) {
348455 this .recoveryPoints = new RecoveryPointsImpl (clientObject .getRecoveryPoints (), this );
349456 }
350457 return recoveryPoints ;
351458 }
352459
353- /** @return Resource collection API of Jobs. */
460+ /**
461+ * Gets the resource collection API of Jobs.
462+ *
463+ * @return Resource collection API of Jobs.
464+ */
354465 public Jobs jobs () {
355466 if (this .jobs == null ) {
356467 this .jobs = new JobsImpl (clientObject .getJobs (), this );
357468 }
358469 return jobs ;
359470 }
360471
361- /** @return Resource collection API of RestorableTimeRanges. */
472+ /**
473+ * Gets the resource collection API of RestorableTimeRanges.
474+ *
475+ * @return Resource collection API of RestorableTimeRanges.
476+ */
362477 public RestorableTimeRanges restorableTimeRanges () {
363478 if (this .restorableTimeRanges == null ) {
364479 this .restorableTimeRanges = new RestorableTimeRangesImpl (clientObject .getRestorableTimeRanges (), this );
365480 }
366481 return restorableTimeRanges ;
367482 }
368483
369- /** @return Resource collection API of ExportJobs. */
484+ /**
485+ * Gets the resource collection API of ExportJobs.
486+ *
487+ * @return Resource collection API of ExportJobs.
488+ */
370489 public ExportJobs exportJobs () {
371490 if (this .exportJobs == null ) {
372491 this .exportJobs = new ExportJobsImpl (clientObject .getExportJobs (), this );
373492 }
374493 return exportJobs ;
375494 }
376495
377- /** @return Resource collection API of ExportJobsOperationResults. */
496+ /**
497+ * Gets the resource collection API of ExportJobsOperationResults.
498+ *
499+ * @return Resource collection API of ExportJobsOperationResults.
500+ */
378501 public ExportJobsOperationResults exportJobsOperationResults () {
379502 if (this .exportJobsOperationResults == null ) {
380503 this .exportJobsOperationResults =
@@ -383,7 +506,11 @@ public ExportJobsOperationResults exportJobsOperationResults() {
383506 return exportJobsOperationResults ;
384507 }
385508
386- /** @return Resource collection API of ResourceGuards. */
509+ /**
510+ * Gets the resource collection API of ResourceGuards. It manages ResourceGuardResource.
511+ *
512+ * @return Resource collection API of ResourceGuards.
513+ */
387514 public ResourceGuards resourceGuards () {
388515 if (this .resourceGuards == null ) {
389516 this .resourceGuards = new ResourceGuardsImpl (clientObject .getResourceGuards (), this );
0 commit comments