BackupShortTermRetentionPolicyResource IOperationSource <BackupShortTermRetentionPolicyResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = BackupShortTermRetentionPolicyData.DeserializeBackupShortTermRetentionPolicyData(document.RootElement); return(new BackupShortTermRetentionPolicyResource(_client, data)); }
public async Task <Response <BackupShortTermRetentionPolicyData> > GetAsync(string subscriptionId, string resourceGroupName, string serverName, string databaseName, ShortTermRetentionPolicyName policyName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (serverName == null) { throw new ArgumentNullException(nameof(serverName)); } if (databaseName == null) { throw new ArgumentNullException(nameof(databaseName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, serverName, databaseName, policyName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { BackupShortTermRetentionPolicyData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = BackupShortTermRetentionPolicyData.DeserializeBackupShortTermRetentionPolicyData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal BackupShortTermRetentionPolicy(ArmResource options, BackupShortTermRetentionPolicyData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _backupShortTermRetentionPoliciesRestClient = new BackupShortTermRetentionPoliciesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
public virtual BackupShortTermRetentionPolicyUpdateOperation Update(BackupShortTermRetentionPolicyData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("BackupShortTermRetentionPolicy.Update"); scope.Start(); try { var response = _backupShortTermRetentionPoliciesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, parameters, cancellationToken); var operation = new BackupShortTermRetentionPolicyUpdateOperation(this, _clientDiagnostics, Pipeline, _backupShortTermRetentionPoliciesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <BackupShortTermRetentionPolicyCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, ShortTermRetentionPolicyName policyName, BackupShortTermRetentionPolicyData parameters, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _backupShortTermRetentionPolicyClientDiagnostics.CreateScope("BackupShortTermRetentionPolicyCollection.CreateOrUpdate"); scope.Start(); try { var response = await _backupShortTermRetentionPolicyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, policyName, parameters, cancellationToken).ConfigureAwait(false); var operation = new BackupShortTermRetentionPolicyCreateOrUpdateOperation(ArmClient, _backupShortTermRetentionPolicyClientDiagnostics, Pipeline, _backupShortTermRetentionPolicyRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, policyName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal BackupShortTermRetentionPolicyResource(ArmClient client, BackupShortTermRetentionPolicyData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <BackupShortTermRetentionPolicyResource> Update(WaitUntil waitUntil, BackupShortTermRetentionPolicyData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _backupShortTermRetentionPolicyClientDiagnostics.CreateScope("BackupShortTermRetentionPolicyResource.Update"); scope.Start(); try { var response = _backupShortTermRetentionPolicyRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); var operation = new SqlArmOperation <BackupShortTermRetentionPolicyResource>(new BackupShortTermRetentionPolicyOperationSource(Client), _backupShortTermRetentionPolicyClientDiagnostics, Pipeline, _backupShortTermRetentionPolicyRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <ArmOperation <BackupShortTermRetentionPolicy> > UpdateAsync(bool waitForCompletion, BackupShortTermRetentionPolicyData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _backupShortTermRetentionPolicyClientDiagnostics.CreateScope("BackupShortTermRetentionPolicy.Update"); scope.Start(); try { var response = await _backupShortTermRetentionPolicyRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, parameters, cancellationToken).ConfigureAwait(false); var operation = new SqlArmOperation <BackupShortTermRetentionPolicy>(new BackupShortTermRetentionPolicyOperationSource(Client), _backupShortTermRetentionPolicyClientDiagnostics, Pipeline, _backupShortTermRetentionPolicyRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, parameters).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal BackupShortTermRetentionPolicy(ArmClient armClient, BackupShortTermRetentionPolicyData data) : this(armClient, data.Id) { HasData = true; _data = data; }