MonitoringSettingResource IOperationSource <MonitoringSettingResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = MonitoringSettingResourceData.DeserializeMonitoringSettingResourceData(document.RootElement); return(new MonitoringSettingResource(_client, data)); }
public async Task <Response <MonitoringSettingResourceData> > GetAsync(string subscriptionId, string resourceGroupName, string serviceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); using var message = CreateGetRequest(subscriptionId, resourceGroupName, serviceName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { MonitoringSettingResourceData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = MonitoringSettingResourceData.DeserializeMonitoringSettingResourceData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal MonitoringSettingResource(ArmClient client, MonitoringSettingResourceData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <MonitoringSettingResource> CreateOrUpdate(WaitUntil waitUntil, MonitoringSettingResourceData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _monitoringSettingResourceMonitoringSettingsClientDiagnostics.CreateScope("MonitoringSettingResource.CreateOrUpdate"); scope.Start(); try { var response = _monitoringSettingResourceMonitoringSettingsRestClient.UpdatePut(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, data, cancellationToken); var operation = new AppPlatformArmOperation <MonitoringSettingResource>(new MonitoringSettingResourceOperationSource(Client), _monitoringSettingResourceMonitoringSettingsClientDiagnostics, Pipeline, _monitoringSettingResourceMonitoringSettingsRestClient.CreateUpdatePutRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }