Esempio n. 1
0
        /// <summary>
        /// Create or update tags with the resource.
        /// </summary>
        /// <param name="parameters"> The tags to create or update. </param>
        /// <param name="waitForCompletion"> Waits for the completion of the long running operations. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
        /// <returns> The created or updated tags. </returns>
        public virtual async Task <TagCreateOrUpdateOperation> CreateOrUpdateAsync(TagResourceData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (parameters is null)
            {
                throw new ArgumentException($"{nameof(parameters)} provided cannot be null.", nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("TagResource.CreateOrUpdate");
            scope.Start();

            try
            {
                var response = await _restClient.CreateOrUpdateAtScopeAsync(Id, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new TagCreateOrUpdateOperation(this, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 2
0
 /// <summary> Initializes a new instance of the <see cref = "TagResource"/> class. </summary>
 /// <param name="options"> The client parameters to use in these operations. </param>
 /// <param name="resource"> The resource that is the target of operations. </param>
 internal TagResource(ArmResource options, TagResourceData resource)
     : base(options, resource.Id)
 {
     _data              = resource;
     HasData            = true;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new TagRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Esempio n. 3
0
 /// <summary>
 /// Create or update tags with the resource.
 /// </summary>
 /// <param name="parameters"> The tags to create or update. </param>
 /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
 /// <returns> The created or updated tags. </returns>
 /// <remarks>
 /// <see href="https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning">Details on long running operation object.</see>
 /// </remarks>
 public virtual TagCreateOrUpdateOperation StartCreateOrUpdate(TagResourceData parameters, CancellationToken cancellationToken = default)
 {
     using var scope = Diagnostics.CreateScope("TagsOperations.StartCreateOrUpdateAtScope");
     scope.Start();
     try
     {
         var response = RestClient.CreateOrUpdateAtScope(Id, parameters, cancellationToken);
         return(new TagCreateOrUpdateOperation(this, response));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Create or update tags with the resource.
        /// </summary>
        /// <param name="parameters"> The tags to create or update. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param>
        /// <returns> The created or updated tags. </returns>
        public virtual Response <TagResource> CreateOrUpdate(TagResourceData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters is null)
            {
                throw new ArgumentException($"{nameof(parameters)} provided cannot be null.", nameof(parameters));
            }

            using var scope = Diagnostics.CreateScope("TagsOperations.CreateOrUpdateAtScope");
            scope.Start();

            try
            {
                var operation = StartCreateOrUpdate(parameters, cancellationToken);
                return(operation.WaitForCompletion(cancellationToken));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 5
0
 internal TagResource(ArmClient client, TagResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Esempio n. 6
0
        public virtual ArmOperation <TagResource> CreateOrUpdate(WaitUntil waitUntil, TagResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _tagResourceTagsClientDiagnostics.CreateScope("TagResource.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _tagResourceTagsRestClient.CreateOrUpdateAtScope(Id.Parent, data, cancellationToken);
                var operation = new ResourcesArmOperation <TagResource>(Response.FromValue(new TagResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 7
0
        public virtual async Task <ArmOperation <TagResource> > CreateOrUpdateAsync(WaitUntil waitUntil, TagResourceData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _tagResourceTagsClientDiagnostics.CreateScope("TagResource.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _tagResourceTagsRestClient.CreateOrUpdateAtScopeAsync(Id.Parent, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ResourcesArmOperation <TagResource>(Response.FromValue(new TagResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 8
0
 /// <summary> Initializes a new instance of the <see cref = "TagResource"/> class. </summary>
 /// <param name="options"> The client parameters to use in these operations. </param>
 /// <param name="resource"> The resource that is the target of operations. </param>
 internal TagResource(OperationsBase options, TagResourceData resource)
     : base(options, resource.Id)
 {
     Data = resource;
 }
        public virtual TagResourceCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, TagResourceData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _tagResourceTagsClientDiagnostics.CreateScope("TagResource.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _tagResourceTagsRestClient.CreateOrUpdateAtScope(Id.Parent, parameters, cancellationToken);
                var operation = new TagResourceCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }