Example #1
0
 internal ServerJobAgentJobVersionStep(ArmResource options, JobStepData resource) : base(options, resource.Id)
 {
     HasData             = true;
     _data               = resource;
     _clientDiagnostics  = new ClientDiagnostics(ClientOptions);
     _jobStepsRestClient = new JobStepsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Example #2
0
 internal ServerJobAgentJobStep(ArmClient client, JobStepData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual ServerJobAgentJobStepCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string stepName, JobStepData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(stepName, nameof(stepName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _serverJobAgentJobStepJobStepsClientDiagnostics.CreateScope("ServerJobAgentJobStepCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _serverJobAgentJobStepJobStepsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, stepName, parameters, cancellationToken);
                var operation = new ServerJobAgentJobStepCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #4
0
        public virtual async Task <ArmOperation <ServerJobAgentJobStep> > CreateOrUpdateAsync(WaitUntil waitUntil, string stepName, JobStepData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(stepName, nameof(stepName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _serverJobAgentJobStepJobStepsClientDiagnostics.CreateScope("ServerJobAgentJobStepCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _serverJobAgentJobStepJobStepsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, stepName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <ServerJobAgentJobStep>(Response.FromValue(new ServerJobAgentJobStep(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal ServerJobAgentJobVersionStepResource(ArmClient client, JobStepData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Example #6
0
        public async virtual Task <JobStepCreateOrUpdateOperation> CreateOrUpdateAsync(string stepName, JobStepData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (stepName == null)
            {
                throw new ArgumentNullException(nameof(stepName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

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

                var operation = new JobStepCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #7
0
        public virtual ArmOperation <ServerJobAgentJobStepResource> Update(WaitUntil waitUntil, JobStepData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _serverJobAgentJobStepJobStepsClientDiagnostics.CreateScope("ServerJobAgentJobStepResource.Update");
            scope.Start();
            try
            {
                var response  = _serverJobAgentJobStepJobStepsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new SqlArmOperation <ServerJobAgentJobStepResource>(Response.FromValue(new ServerJobAgentJobStepResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }