public async virtual Task <MaintenanceWindowsCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string maintenanceWindowName, MaintenanceWindowsData parameters, CancellationToken cancellationToken = default) { if (maintenanceWindowName == null) { throw new ArgumentNullException(nameof(maintenanceWindowName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _maintenanceWindowsMaintenanceWindowsClientDiagnostics.CreateScope("MaintenanceWindows.CreateOrUpdate"); scope.Start(); try { var response = await _maintenanceWindowsMaintenanceWindowsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, maintenanceWindowName, parameters, cancellationToken).ConfigureAwait(false); var operation = new MaintenanceWindowsCreateOrUpdateOperation(response); if (waitForCompletion) { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation> CreateOrUpdateAsync(WaitUntil waitUntil, string maintenanceWindowName, MaintenanceWindowsData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(maintenanceWindowName, nameof(maintenanceWindowName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _maintenanceWindowsMaintenanceWindowsClientDiagnostics.CreateScope("MaintenanceWindowsResource.CreateOrUpdate"); scope.Start(); try { var response = await _maintenanceWindowsMaintenanceWindowsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, maintenanceWindowName, data, cancellationToken).ConfigureAwait(false); var operation = new SqlArmOperation(response); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }