public async Task <Response <StorageQueue> > CreateAsync(string resourceGroupName, string accountName, string queueName, StorageQueue queue, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (queue == null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

            using var message = CreateCreateRequest(resourceGroupName, accountName, queueName, queue);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = StorageQueue.DeserializeStorageQueue(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Exemplo n.º 2
0
 public static StorageQueue GetStorageQueue(this ArmClient client, ResourceIdentifier id)
 {
     return(client.GetClient(() =>
     {
         StorageQueue.ValidateResourceId(id);
         return new StorageQueue(client, id);
     }
                             ));
 }
 public virtual async Task <Response <StorageQueue> > UpdateAsync(string resourceGroupName, string accountName, string queueName, StorageQueue queue, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("QueueOperations.Update");
     scope.Start();
     try
     {
         return(await RestClient.UpdateAsync(resourceGroupName, accountName, queueName, queue, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 public virtual Response <StorageQueue> Create(string resourceGroupName, string accountName, string queueName, StorageQueue queue, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("QueueOperations.Create");
     scope.Start();
     try
     {
         return(RestClient.Create(resourceGroupName, accountName, queueName, queue, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 public static StorageQueue GetStorageQueue(this ArmClient armClient, ResourceIdentifier id)
 {
     StorageQueue.ValidateResourceId(id);
     return(new StorageQueue(armClient, id));
 }
        internal HttpMessage CreateCreateRequest(string resourceGroupName, string accountName, string queueName, StorageQueue queue)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/resourceGroups/", false);
            uri.AppendPath(resourceGroupName, true);
            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
            uri.AppendPath(accountName, true);
            uri.AppendPath("/queueServices/default/queues/", false);
            uri.AppendPath(queueName, true);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Content-Type", "application/json");
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(queue);
            request.Content = content;
            return(message);
        }