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

            return(new StorageResource(_client, data));
        }
Example #2
0
        public async Task <Response <StorageResourceData> > GetAsync(string subscriptionId, string resourceGroupName, string serviceName, string storageName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName));
            Argument.AssertNotNullOrEmpty(storageName, nameof(storageName));

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, serviceName, storageName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                StorageResourceData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = StorageResourceData.DeserializeStorageResourceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Example #3
0
        public virtual ArmOperation <StorageResource> Update(WaitUntil waitUntil, StorageResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _storageResourceStoragesClientDiagnostics.CreateScope("StorageResource.Update");
            scope.Start();
            try
            {
                var response  = _storageResourceStoragesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new AppPlatformArmOperation <StorageResource>(new StorageResourceOperationSource(Client), _storageResourceStoragesClientDiagnostics, Pipeline, _storageResourceStoragesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #4
0
 internal StorageResource(ArmClient client, StorageResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }