Exemplo n.º 1
0
        AppPlatformServiceResource IOperationSource <AppPlatformServiceResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AppPlatformServiceResourceData.DeserializeAppPlatformServiceResourceData(document.RootElement);

            return(new AppPlatformServiceResource(_client, data));
        }
Exemplo n.º 2
0
        public virtual async Task <ArmOperation <AppPlatformServiceResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string serviceName, AppPlatformServiceResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _appPlatformServiceResourceServicesClientDiagnostics.CreateScope("AppPlatformServiceResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _appPlatformServiceResourceServicesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, serviceName, data, cancellationToken).ConfigureAwait(false);

                var operation = new AppPlatformArmOperation <AppPlatformServiceResource>(new AppPlatformServiceResourceOperationSource(Client), _appPlatformServiceResourceServicesClientDiagnostics, Pipeline, _appPlatformServiceResourceServicesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, serviceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }