internal JobTargetGroup(ArmResource options, JobTargetGroupData resource) : base(options, resource.Id)
 {
     HasData                    = true;
     _data                      = resource;
     _clientDiagnostics         = new ClientDiagnostics(ClientOptions);
     _jobTargetGroupsRestClient = new JobTargetGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
        public virtual JobTargetGroupCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string targetGroupName, JobTargetGroupData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(targetGroupName, nameof(targetGroupName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _jobTargetGroupClientDiagnostics.CreateScope("JobTargetGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _jobTargetGroupRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, targetGroupName, parameters, cancellationToken);
                var operation = new JobTargetGroupCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#3
0
 internal JobTargetGroup(ArmClient armClient, JobTargetGroupData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
 internal JobTargetGroupResource(ArmClient client, JobTargetGroupData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
示例#5
0
        public async virtual Task <ArmOperation <JobTargetGroup> > CreateOrUpdateAsync(bool waitForCompletion, string targetGroupName, JobTargetGroupData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(targetGroupName, nameof(targetGroupName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _jobTargetGroupClientDiagnostics.CreateScope("JobTargetGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _jobTargetGroupRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, targetGroupName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <JobTargetGroup>(Response.FromValue(new JobTargetGroup(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#6
0
        public virtual ArmOperation <JobTargetGroupResource> Update(WaitUntil waitUntil, JobTargetGroupData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _jobTargetGroupClientDiagnostics.CreateScope("JobTargetGroupResource.Update");
            scope.Start();
            try
            {
                var response  = _jobTargetGroupRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new SqlArmOperation <JobTargetGroupResource>(Response.FromValue(new JobTargetGroupResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <JobTargetGroupCreateOrUpdateOperation> CreateOrUpdateAsync(string targetGroupName, JobTargetGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (targetGroupName == null)
            {
                throw new ArgumentNullException(nameof(targetGroupName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("JobTargetGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _jobTargetGroupsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, targetGroupName, parameters, cancellationToken).ConfigureAwait(false);

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