ArmApplicationResource IOperationSource <ArmApplicationResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = ArmApplicationData.DeserializeArmApplicationData(document.RootElement); return(new ArmApplicationResource(_client, data)); }
public async Task <Response <ArmApplicationData> > GetAsync(string subscriptionId, string resourceGroupName, string applicationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(applicationName, nameof(applicationName)); using var message = CreateGetRequest(subscriptionId, resourceGroupName, applicationName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ArmApplicationData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ArmApplicationData.DeserializeArmApplicationData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal ArmApplicationResource(ArmClient client, ArmApplicationData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual async Task <ArmOperation <ArmApplicationResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string applicationName, ArmApplicationData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(applicationName, nameof(applicationName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _armApplicationApplicationsClientDiagnostics.CreateScope("ArmApplicationCollection.CreateOrUpdate"); scope.Start(); try { var response = await _armApplicationApplicationsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, applicationName, data, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <ArmApplicationResource>(new ArmApplicationOperationSource(Client), _armApplicationApplicationsClientDiagnostics, Pipeline, _armApplicationApplicationsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, applicationName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }