Example #1
0
        ConfigServerResource IOperationSource <ConfigServerResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ConfigServerResourceData.DeserializeConfigServerResourceData(document.RootElement);

            return(new ConfigServerResource(_client, data));
        }
Example #2
0
        public async Task <Response <ConfigServerResourceData> > 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:
            {
                ConfigServerResourceData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = ConfigServerResourceData.DeserializeConfigServerResourceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Example #3
0
 internal ConfigServerResource(ArmClient client, ConfigServerResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Example #4
0
        public virtual ArmOperation <ConfigServerResource> CreateOrUpdate(WaitUntil waitUntil, ConfigServerResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _configServerResourceConfigServersClientDiagnostics.CreateScope("ConfigServerResource.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _configServerResourceConfigServersRestClient.UpdatePut(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, data, cancellationToken);
                var operation = new AppPlatformArmOperation <ConfigServerResource>(new ConfigServerResourceOperationSource(Client), _configServerResourceConfigServersClientDiagnostics, Pipeline, _configServerResourceConfigServersRestClient.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;
            }
        }