ConfidentialLedgerResource IOperationSource <ConfidentialLedgerResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = ConfidentialLedgerData.DeserializeConfidentialLedgerData(document.RootElement); return(new ConfidentialLedgerResource(_client, data)); }
public async Task <Response <ConfidentialLedgerData> > GetAsync(string subscriptionId, string resourceGroupName, string ledgerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(ledgerName, nameof(ledgerName)); using var message = CreateGetRequest(subscriptionId, resourceGroupName, ledgerName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ConfidentialLedgerData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ConfidentialLedgerData.DeserializeConfidentialLedgerData(document.RootElement); return(Response.FromValue(value, message.Response)); }
public virtual async Task <ArmOperation <ConfidentialLedgerResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string ledgerName, ConfidentialLedgerData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ledgerName, nameof(ledgerName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _confidentialLedgerLedgerClientDiagnostics.CreateScope("ConfidentialLedgerCollection.CreateOrUpdate"); scope.Start(); try { var response = await _confidentialLedgerLedgerRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, ledgerName, data, cancellationToken).ConfigureAwait(false); var operation = new ConfidentialLedgerArmOperation <ConfidentialLedgerResource>(new ConfidentialLedgerOperationSource(Client), _confidentialLedgerLedgerClientDiagnostics, Pipeline, _confidentialLedgerLedgerRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, ledgerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal ConfidentialLedgerResource(ArmClient client, ConfidentialLedgerData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <ConfidentialLedgerResource> Update(WaitUntil waitUntil, ConfidentialLedgerData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _confidentialLedgerLedgerClientDiagnostics.CreateScope("ConfidentialLedgerResource.Update"); scope.Start(); try { var response = _confidentialLedgerLedgerRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken); var operation = new ConfidentialLedgerArmOperation <ConfidentialLedgerResource>(new ConfidentialLedgerOperationSource(Client), _confidentialLedgerLedgerClientDiagnostics, Pipeline, _confidentialLedgerLedgerRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }