public virtual QueueCreateOperation CreateOrUpdate(string queueName, StorageQueueData queue, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (queue == null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

            using var scope = _clientDiagnostics.CreateScope("StorageQueueCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _queueRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, queueName, queue, cancellationToken);
                var operation = new QueueCreateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #2
0
 internal StorageQueue(ArmResource options, StorageQueueData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new QueueRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
        public virtual Response <StorageQueueResource> Update(StorageQueueData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _storageQueueQueueClientDiagnostics.CreateScope("StorageQueueResource.Update");
            scope.Start();
            try
            {
                var response = _storageQueueQueueRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Name, data, cancellationToken);
                return(Response.FromValue(new StorageQueueResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #4
0
        public async virtual Task <Response <StorageQueue> > UpdateAsync(StorageQueueData queue, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(queue, nameof(queue));

            using var scope = _storageQueueQueueClientDiagnostics.CreateScope("StorageQueue.Update");
            scope.Start();
            try
            {
                var response = await _storageQueueQueueRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Name, queue, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new StorageQueue(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #5
0
        public virtual Response <StorageQueue> Update(StorageQueueData queue, CancellationToken cancellationToken = default)
        {
            if (queue == null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

            using var scope = _clientDiagnostics.CreateScope("StorageQueue.Update");
            scope.Start();
            try
            {
                var response = _restClient.Update(Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, queue, cancellationToken);
                return(Response.FromValue(new StorageQueue(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #6
0
        public async Task <Response <StorageQueueData> > CreateAsync(string subscriptionId, string resourceGroupName, string accountName, string queueName, StorageQueueData queue, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(accountName, nameof(accountName));
            Argument.AssertNotNullOrEmpty(queueName, nameof(queueName));
            Argument.AssertNotNull(queue, nameof(queue));

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

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

                value = StorageQueueData.DeserializeStorageQueueData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        public async Task <Response <StorageQueueData> > CreateAsync(string resourceGroupName, string accountName, string queueServiceName, string queueName, StorageQueueData queue, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }
            if (queueServiceName == null)
            {
                throw new ArgumentNullException(nameof(queueServiceName));
            }
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (queue == null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

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

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

                value = StorageQueueData.DeserializeStorageQueueData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal StorageQueueResource(ArmClient client, StorageQueueData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public async virtual Task <ArmOperation <StorageQueue> > CreateOrUpdateAsync(bool waitForCompletion, string queueName, StorageQueueData queue, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(queueName, nameof(queueName));
            Argument.AssertNotNull(queue, nameof(queue));

            using var scope = _storageQueueQueueClientDiagnostics.CreateScope("StorageQueueCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _storageQueueQueueRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, queueName, queue, cancellationToken).ConfigureAwait(false);

                var operation = new StorageArmOperation <StorageQueue>(Response.FromValue(new StorageQueue(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ArmOperation <StorageQueueResource> CreateOrUpdate(WaitUntil waitUntil, string queueName, StorageQueueData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(queueName, nameof(queueName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _storageQueueQueueClientDiagnostics.CreateScope("StorageQueueCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _storageQueueQueueRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, queueName, data, cancellationToken);
                var operation = new StorageArmOperation <StorageQueueResource>(Response.FromValue(new StorageQueueResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #11
0
        internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string accountName, string queueName, StorageQueueData 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("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(queue);
            request.Content = content;
            _userAgent.Apply(message);
            return(message);
        }
 internal StorageQueue(ArmClient armClient, StorageQueueData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public async virtual Task <QueueCreateOperation> CreateOrUpdateAsync(string queueName, StorageQueueData queue, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException(nameof(queueName));
            }
            if (queue == null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

            using var scope = _clientDiagnostics.CreateScope("StorageQueueContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _restClient.CreateAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, queueName, queue, cancellationToken).ConfigureAwait(false);

                var operation = new QueueCreateOperation(Parent, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }