AppServicePlanResource IOperationSource <AppServicePlanResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = AppServicePlanData.DeserializeAppServicePlanData(document.RootElement); return(new AppServicePlanResource(_client, data)); }
internal AppServicePlan(ArmResource options, AppServicePlanData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _appServicePlansRestClient = new AppServicePlansRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
internal AppServicePlan(ArmClient client, AppServicePlanData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual async Task <ArmOperation <AppServicePlanResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string name, AppServicePlanData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(name, nameof(name)); Argument.AssertNotNull(data, nameof(data)); using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlanCollection.CreateOrUpdate"); scope.Start(); try { var response = await _appServicePlanRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, name, data, cancellationToken).ConfigureAwait(false); var operation = new AppServiceArmOperation <AppServicePlanResource>(new AppServicePlanOperationSource(Client), _appServicePlanClientDiagnostics, Pipeline, _appServicePlanRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <AppServicePlan> CreateOrUpdate(bool waitForCompletion, string name, AppServicePlanData appServicePlan, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(name, nameof(name)); Argument.AssertNotNull(appServicePlan, nameof(appServicePlan)); using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlanCollection.CreateOrUpdate"); scope.Start(); try { var response = _appServicePlanRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, name, appServicePlan, cancellationToken); var operation = new AppServiceArmOperation <AppServicePlan>(new AppServicePlanOperationSource(Client), _appServicePlanClientDiagnostics, Pipeline, _appServicePlanRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, appServicePlan).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <AppServicePlanCreateOrUpdateOperation> CreateOrUpdateAsync(string name, AppServicePlanData appServicePlan, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (appServicePlan == null) { throw new ArgumentNullException(nameof(appServicePlan)); } using var scope = _clientDiagnostics.CreateScope("AppServicePlanCollection.CreateOrUpdate"); scope.Start(); try { var response = await _appServicePlansRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, name, appServicePlan, cancellationToken).ConfigureAwait(false); var operation = new AppServicePlanCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _appServicePlansRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, appServicePlan).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }