internal DiskEncryptionSet(ArmResource options, DiskEncryptionSetData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new DiskEncryptionSetsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
DiskEncryptionSetResource IOperationSource <DiskEncryptionSetResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = DiskEncryptionSetData.DeserializeDiskEncryptionSetData(document.RootElement); return(new DiskEncryptionSetResource(_client, data)); }
internal DiskEncryptionSet(ArmResource options, DiskEncryptionSetData data) : base(options, data.Id) { HasData = true; _data = data; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _diskEncryptionSetsRestClient = new DiskEncryptionSetsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif }
public async Task <Response <DiskEncryptionSetData> > GetAsync(string resourceGroupName, string diskEncryptionSetName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (diskEncryptionSetName == null) { throw new ArgumentNullException(nameof(diskEncryptionSetName)); } using var message = CreateGetRequest(resourceGroupName, diskEncryptionSetName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { DiskEncryptionSetData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = DiskEncryptionSetData.DeserializeDiskEncryptionSetData(document.RootElement); return(Response.FromValue(value, message.Response)); }
public async virtual Task <DiskEncryptionSetCreateOrUpdateOperation> CreateOrUpdateAsync(string diskEncryptionSetName, DiskEncryptionSetData diskEncryptionSet, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (diskEncryptionSetName == null) { throw new ArgumentNullException(nameof(diskEncryptionSetName)); } if (diskEncryptionSet == null) { throw new ArgumentNullException(nameof(diskEncryptionSet)); } using var scope = _clientDiagnostics.CreateScope("DiskEncryptionSetContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, diskEncryptionSetName, diskEncryptionSet, cancellationToken).ConfigureAwait(false); var operation = new DiskEncryptionSetCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, diskEncryptionSetName, diskEncryptionSet).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response> CreateOrUpdateAsync(string resourceGroupName, string diskEncryptionSetName, DiskEncryptionSetData diskEncryptionSet, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (diskEncryptionSetName == null) { throw new ArgumentNullException(nameof(diskEncryptionSetName)); } if (diskEncryptionSet == null) { throw new ArgumentNullException(nameof(diskEncryptionSet)); } using var message = CreateCreateOrUpdateRequest(resourceGroupName, diskEncryptionSetName, diskEncryptionSet); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 202: return(message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string diskEncryptionSetName, DiskEncryptionSetData diskEncryptionSet) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Compute/diskEncryptionSets/", false); uri.AppendPath(diskEncryptionSetName, true); uri.AppendQuery("api-version", "2020-12-01", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(diskEncryptionSet); request.Content = content; message.SetProperty("UserAgentOverride", _userAgent); return(message); }
internal DiskEncryptionSet(ArmClient armClient, DiskEncryptionSetData data) : this(armClient, data.Id) { HasData = true; _data = data; }
public async virtual Task <ArmOperation <DiskEncryptionSet> > CreateOrUpdateAsync(bool waitForCompletion, string diskEncryptionSetName, DiskEncryptionSetData diskEncryptionSet, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diskEncryptionSetName, nameof(diskEncryptionSetName)); Argument.AssertNotNull(diskEncryptionSet, nameof(diskEncryptionSet)); using var scope = _diskEncryptionSetClientDiagnostics.CreateScope("DiskEncryptionSetCollection.CreateOrUpdate"); scope.Start(); try { var response = await _diskEncryptionSetRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, diskEncryptionSetName, diskEncryptionSet, cancellationToken).ConfigureAwait(false); var operation = new ComputeArmOperation <DiskEncryptionSet>(new DiskEncryptionSetOperationSource(Client), _diskEncryptionSetClientDiagnostics, Pipeline, _diskEncryptionSetRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, diskEncryptionSetName, diskEncryptionSet).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal DiskEncryptionSetResource(ArmClient client, DiskEncryptionSetData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual DiskEncryptionSetCreateOrUpdateOperation CreateOrUpdate(string diskEncryptionSetName, DiskEncryptionSetData diskEncryptionSet, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (diskEncryptionSetName == null) { throw new ArgumentNullException(nameof(diskEncryptionSetName)); } if (diskEncryptionSet == null) { throw new ArgumentNullException(nameof(diskEncryptionSet)); } using var scope = _clientDiagnostics.CreateScope("DiskEncryptionSetCollection.CreateOrUpdate"); scope.Start(); try { var response = _diskEncryptionSetsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, diskEncryptionSetName, diskEncryptionSet, cancellationToken); var operation = new DiskEncryptionSetCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _diskEncryptionSetsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, diskEncryptionSetName, diskEncryptionSet).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <DiskEncryptionSetResource> CreateOrUpdate(WaitUntil waitUntil, string diskEncryptionSetName, DiskEncryptionSetData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diskEncryptionSetName, nameof(diskEncryptionSetName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _diskEncryptionSetClientDiagnostics.CreateScope("DiskEncryptionSetCollection.CreateOrUpdate"); scope.Start(); try { var response = _diskEncryptionSetRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, diskEncryptionSetName, data, cancellationToken); var operation = new ComputeArmOperation <DiskEncryptionSetResource>(new DiskEncryptionSetOperationSource(Client), _diskEncryptionSetClientDiagnostics, Pipeline, _diskEncryptionSetRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, diskEncryptionSetName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }