public virtual JobCreateOrUpdateOperation CreateOrUpdate(string jobName, SqlJobData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (jobName == null) { throw new ArgumentNullException(nameof(jobName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("SqlJobCollection.CreateOrUpdate"); scope.Start(); try { var response = _jobsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, jobName, parameters, cancellationToken); var operation = new JobCreateOrUpdateOperation(Parent, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal SqlJob(ArmResource options, SqlJobData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _jobsRestClient = new JobsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); _jobExecutionsRestClient = new JobExecutionsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
public virtual ArmOperation <SqlJobResource> Update(WaitUntil waitUntil, SqlJobData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _sqlJobJobsClientDiagnostics.CreateScope("SqlJobResource.Update"); scope.Start(); try { var response = _sqlJobJobsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); var operation = new SqlArmOperation <SqlJobResource>(Response.FromValue(new SqlJobResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <SqlJobResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string jobName, SqlJobData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _sqlJobJobsClientDiagnostics.CreateScope("SqlJobCollection.CreateOrUpdate"); scope.Start(); try { var response = await _sqlJobJobsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, jobName, data, cancellationToken).ConfigureAwait(false); var operation = new SqlArmOperation <SqlJobResource>(Response.FromValue(new SqlJobResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal SqlJob(ArmClient client, SqlJobData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <SqlJob> CreateOrUpdate(bool waitForCompletion, string jobName, SqlJobData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _sqlJobJobsClientDiagnostics.CreateScope("SqlJobCollection.CreateOrUpdate"); scope.Start(); try { var response = _sqlJobJobsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, jobName, parameters, cancellationToken); var operation = new SqlArmOperation <SqlJob>(Response.FromValue(new SqlJob(Client, response), response.GetRawResponse())); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <SqlJobCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string jobName, SqlJobData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _sqlJobJobsClientDiagnostics.CreateScope("SqlJobCollection.CreateOrUpdate"); scope.Start(); try { var response = await _sqlJobJobsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, jobName, parameters, cancellationToken).ConfigureAwait(false); var operation = new SqlJobCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }