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