From ae2c630c7623d6ee92e312d0810c6df4f7451a6f Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Sat, 27 Jan 2018 21:47:46 +0000 Subject: [PATCH] Generated from 00c10e2add6a8d8d5c0cd8c28f8f6f09a3dde3b8 Merge remote-tracking branch 'azure/master' into sqljobs3 --- services/sql/mgmt/2014-04-01/sql/models.go | 110 +- services/sql/mgmt/2014-04-01/sql/version.go | 4 +- .../sql/mgmt/2015-05-01-preview/sql/models.go | 390 ++- .../mgmt/2015-05-01-preview/sql/version.go | 4 +- .../sql/databaseautomatictuning.go | 182 ++ .../mgmt/2017-03-01-preview/sql/jobagents.go | 430 +++ .../2017-03-01-preview/sql/jobcredentials.go | 360 +++ .../2017-03-01-preview/sql/jobexecutions.go | 531 ++++ .../sql/mgmt/2017-03-01-preview/sql/jobs.go | 350 +++ .../mgmt/2017-03-01-preview/sql/jobsteps.go | 545 ++++ .../2017-03-01-preview/sql/jobtargetgroups.go | 358 +++ .../2017-03-01-preview/sql/jobversions.go | 211 ++ .../sql/mgmt/2017-03-01-preview/sql/models.go | 2538 +++++++++++++++-- .../sql/serverautomatictuning.go | 179 ++ .../mgmt/2017-03-01-preview/sql/version.go | 4 +- 15 files changed, 5969 insertions(+), 227 deletions(-) create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/databaseautomatictuning.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobagents.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobcredentials.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobexecutions.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobs.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobsteps.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobtargetgroups.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/jobversions.go create mode 100644 services/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go diff --git a/services/sql/mgmt/2014-04-01/sql/models.go b/services/sql/mgmt/2014-04-01/sql/models.go index ac5d7d38217b..5e7d273492dd 100644 --- a/services/sql/mgmt/2014-04-01/sql/models.go +++ b/services/sql/mgmt/2014-04-01/sql/models.go @@ -626,22 +626,30 @@ func (future DatabasesCreateImportOperationFuture) Result(client DatabasesClient var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesCreateImportOperationFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateImportOperationFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.CreateImportOperationResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure sending request") return } ier, err = client.CreateImportOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure responding to request") + } return } @@ -657,22 +665,30 @@ func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Da var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return d, autorest.NewError("sql.DatabasesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { d, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } d, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -797,22 +813,30 @@ func (future DatabasesExportFuture) Result(client DatabasesClient) (ier ImportEx var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesExportFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.ExportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure sending request") return } ier, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure responding to request") + } return } @@ -828,22 +852,30 @@ func (future DatabasesImportFuture) Result(client DatabasesClient) (ier ImportEx var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesImportFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.ImportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure sending request") return } ier, err = client.ImportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure responding to request") + } return } @@ -859,22 +891,30 @@ func (future DatabasesPauseFuture) Result(client DatabasesClient) (ar autorest.R var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.DatabasesPauseFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.PauseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure sending request") return } ar, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure responding to request") + } return } @@ -890,22 +930,30 @@ func (future DatabasesResumeFuture) Result(client DatabasesClient) (ar autorest. var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.DatabasesResumeFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.ResumeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure sending request") return } ar, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure responding to request") + } return } @@ -921,22 +969,30 @@ func (future DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return d, autorest.NewError("sql.DatabasesUpdateFuture", "Result", "asynchronous operation has not completed") + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { d, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure sending request") return } d, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1401,22 +1457,30 @@ func (future ElasticPoolsCreateOrUpdateFuture) Result(client ElasticPoolsClient) var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.ElasticPoolsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1432,22 +1496,30 @@ func (future ElasticPoolsUpdateFuture) Result(client ElasticPoolsClient) (ep Ela var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.ElasticPoolsUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2178,22 +2250,30 @@ func (future ReplicationLinksFailoverAllowDataLossFuture) Result(client Replicat var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.FailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") return } ar, err = client.FailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } return } @@ -2209,22 +2289,30 @@ func (future ReplicationLinksFailoverFuture) Result(client ReplicationLinksClien var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ReplicationLinksFailoverFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure sending request") return } ar, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure responding to request") + } return } diff --git a/services/sql/mgmt/2014-04-01/sql/version.go b/services/sql/mgmt/2014-04-01/sql/version.go index 97e0377bebd0..2dd0fd91b7e6 100644 --- a/services/sql/mgmt/2014-04-01/sql/version.go +++ b/services/sql/mgmt/2014-04-01/sql/version.go @@ -19,10 +19,10 @@ package sql // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v12.1.1-beta services" + return "Azure-SDK-For-Go/v12.2.1-beta services" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v12.1.1-beta" + return "v12.2.1-beta" } diff --git a/services/sql/mgmt/2015-05-01-preview/sql/models.go b/services/sql/mgmt/2015-05-01-preview/sql/models.go index 487f228d4cd1..d6ce708717e0 100644 --- a/services/sql/mgmt/2015-05-01-preview/sql/models.go +++ b/services/sql/mgmt/2015-05-01-preview/sql/models.go @@ -804,22 +804,30 @@ func (future BackupLongTermRetentionPoliciesCreateOrUpdateFuture) Result(client var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return bltrp, autorest.NewError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return bltrp, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { bltrp, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } bltrp, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1018,22 +1026,30 @@ func (future BackupLongTermRetentionVaultsCreateOrUpdateFuture) Result(client Ba var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return bltrv, autorest.NewError("sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return bltrv, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { bltrv, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } bltrv, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1338,22 +1354,30 @@ func (future DatabasesCreateImportOperationFuture) Result(client DatabasesClient var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesCreateImportOperationFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateImportOperationFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.CreateImportOperationResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure sending request") return } ier, err = client.CreateImportOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure responding to request") + } return } @@ -1369,22 +1393,30 @@ func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Da var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return d, autorest.NewError("sql.DatabasesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { d, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } d, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1509,22 +1541,30 @@ func (future DatabasesExportFuture) Result(client DatabasesClient) (ier ImportEx var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesExportFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.ExportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure sending request") return } ier, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure responding to request") + } return } @@ -1540,22 +1580,30 @@ func (future DatabasesImportFuture) Result(client DatabasesClient) (ier ImportEx var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesImportFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.ImportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure sending request") return } ier, err = client.ImportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure responding to request") + } return } @@ -1571,22 +1619,30 @@ func (future DatabasesPauseFuture) Result(client DatabasesClient) (ar autorest.R var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.DatabasesPauseFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.PauseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure sending request") return } ar, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure responding to request") + } return } @@ -1602,22 +1658,30 @@ func (future DatabasesResumeFuture) Result(client DatabasesClient) (ar autorest. var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.DatabasesResumeFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.ResumeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure sending request") return } ar, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure responding to request") + } return } @@ -1633,22 +1697,30 @@ func (future DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return d, autorest.NewError("sql.DatabasesUpdateFuture", "Result", "asynchronous operation has not completed") + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { d, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure sending request") return } d, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2429,22 +2501,30 @@ func (future ElasticPoolsCreateOrUpdateFuture) Result(client ElasticPoolsClient) var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.ElasticPoolsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2460,22 +2540,30 @@ func (future ElasticPoolsUpdateFuture) Result(client ElasticPoolsClient) (ep Ela var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.ElasticPoolsUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2773,22 +2861,30 @@ func (future EncryptionProtectorsCreateOrUpdateFuture) Result(client EncryptionP var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -3042,22 +3138,30 @@ func (future FailoverGroupsCreateOrUpdateFuture) Result(client FailoverGroupsCli var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } fg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -3073,22 +3177,30 @@ func (future FailoverGroupsDeleteFuture) Result(client FailoverGroupsClient) (ar var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.FailoverGroupsDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -3104,22 +3216,30 @@ func (future FailoverGroupsFailoverFuture) Result(client FailoverGroupsClient) ( var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsFailoverFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure sending request") return } fg, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure responding to request") + } return } @@ -3136,22 +3256,30 @@ func (future FailoverGroupsForceFailoverAllowDataLossFuture) Result(client Failo var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.ForceFailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") return } fg, err = client.ForceFailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } return } @@ -3167,22 +3295,30 @@ func (future FailoverGroupsUpdateFuture) Result(client FailoverGroupsClient) (fg var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsUpdateFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure sending request") return } fg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -4304,22 +4440,30 @@ func (future ReplicationLinksFailoverAllowDataLossFuture) Result(client Replicat var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.FailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") return } ar, err = client.FailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } return } @@ -4335,22 +4479,30 @@ func (future ReplicationLinksFailoverFuture) Result(client ReplicationLinksClien var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ReplicationLinksFailoverFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure sending request") return } ar, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure responding to request") + } return } @@ -4769,22 +4921,30 @@ func (future ServerAzureADAdministratorsCreateOrUpdateFuture) Result(client Serv var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return saaa, autorest.NewError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { saaa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } saaa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -4801,22 +4961,30 @@ func (future ServerAzureADAdministratorsDeleteFuture) Result(client ServerAzureA var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return saaa, autorest.NewError("sql.ServerAzureADAdministratorsDeleteFuture", "Result", "asynchronous operation has not completed") + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { saaa, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure sending request") return } saaa, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -4937,22 +5105,30 @@ func (future ServerCommunicationLinksCreateOrUpdateFuture) Result(client ServerC var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return scl, autorest.NewError("sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return scl, azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { scl, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } scl, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5268,22 +5444,30 @@ func (future ServerKeysCreateOrUpdateFuture) Result(client ServerKeysClient) (sk var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sk, autorest.NewError("sql.ServerKeysCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sk, azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sk, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sk, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5299,22 +5483,30 @@ func (future ServerKeysDeleteFuture) Result(client ServerKeysClient) (ar autores var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ServerKeysDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -5446,22 +5638,30 @@ func (future ServersCreateOrUpdateFuture) Result(client ServersClient) (s Server var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return s, autorest.NewError("sql.ServersCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return s, azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { s, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } s, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5477,22 +5677,30 @@ func (future ServersDeleteFuture) Result(client ServersClient) (ar autorest.Resp var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ServersDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -5508,22 +5716,30 @@ func (future ServersUpdateFuture) Result(client ServersClient) (s Server, err er var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return s, autorest.NewError("sql.ServersUpdateFuture", "Result", "asynchronous operation has not completed") + return s, azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { s, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure sending request") return } s, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -6399,22 +6615,30 @@ func (future SyncAgentsCreateOrUpdateFuture) Result(client SyncAgentsClient) (sa var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sa, autorest.NewError("sql.SyncAgentsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sa, azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -6430,22 +6654,30 @@ func (future SyncAgentsDeleteFuture) Result(client SyncAgentsClient) (ar autores var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncAgentsDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -7042,22 +7274,30 @@ func (future SyncGroupsCreateOrUpdateFuture) Result(client SyncGroupsClient) (sg var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sg, autorest.NewError("sql.SyncGroupsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7073,22 +7313,30 @@ func (future SyncGroupsDeleteFuture) Result(client SyncGroupsClient) (ar autores var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncGroupsDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -7105,22 +7353,30 @@ func (future SyncGroupsRefreshHubSchemaFuture) Result(client SyncGroupsClient) ( var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncGroupsRefreshHubSchemaFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.RefreshHubSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure sending request") return } ar, err = client.RefreshHubSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure responding to request") + } return } @@ -7136,22 +7392,30 @@ func (future SyncGroupsUpdateFuture) Result(client SyncGroupsClient) (sg SyncGro var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sg, autorest.NewError("sql.SyncGroupsUpdateFuture", "Result", "asynchronous operation has not completed") + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure sending request") return } sg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7357,22 +7621,30 @@ func (future SyncMembersCreateOrUpdateFuture) Result(client SyncMembersClient) ( var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sm, autorest.NewError("sql.SyncMembersCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sm, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sm, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7388,22 +7660,30 @@ func (future SyncMembersDeleteFuture) Result(client SyncMembersClient) (ar autor var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncMembersDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -7420,22 +7700,30 @@ func (future SyncMembersRefreshMemberSchemaFuture) Result(client SyncMembersClie var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncMembersRefreshMemberSchemaFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.RefreshMemberSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure sending request") return } ar, err = client.RefreshMemberSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure responding to request") + } return } @@ -7451,22 +7739,30 @@ func (future SyncMembersUpdateFuture) Result(client SyncMembersClient) (sm SyncM var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sm, autorest.NewError("sql.SyncMembersUpdateFuture", "Result", "asynchronous operation has not completed") + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sm, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure sending request") return } sm, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7850,22 +8146,30 @@ func (future VirtualNetworkRulesCreateOrUpdateFuture) Result(client VirtualNetwo var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return vnr, autorest.NewError("sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return vnr, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { vnr, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } vnr, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7882,21 +8186,29 @@ func (future VirtualNetworkRulesDeleteFuture) Result(client VirtualNetworkRulesC var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.VirtualNetworkRulesDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure responding to request") + } return } diff --git a/services/sql/mgmt/2015-05-01-preview/sql/version.go b/services/sql/mgmt/2015-05-01-preview/sql/version.go index 97e0377bebd0..2dd0fd91b7e6 100644 --- a/services/sql/mgmt/2015-05-01-preview/sql/version.go +++ b/services/sql/mgmt/2015-05-01-preview/sql/version.go @@ -19,10 +19,10 @@ package sql // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v12.1.1-beta services" + return "Azure-SDK-For-Go/v12.2.1-beta services" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v12.1.1-beta" + return "v12.2.1-beta" } diff --git a/services/sql/mgmt/2017-03-01-preview/sql/databaseautomatictuning.go b/services/sql/mgmt/2017-03-01-preview/sql/databaseautomatictuning.go new file mode 100644 index 000000000000..eb9c18256106 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/databaseautomatictuning.go @@ -0,0 +1,182 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// DatabaseAutomaticTuningClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type DatabaseAutomaticTuningClient struct { + BaseClient +} + +// NewDatabaseAutomaticTuningClient creates an instance of the DatabaseAutomaticTuningClient client. +func NewDatabaseAutomaticTuningClient(subscriptionID string) DatabaseAutomaticTuningClient { + return NewDatabaseAutomaticTuningClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAutomaticTuningClientWithBaseURI creates an instance of the DatabaseAutomaticTuningClient client. +func NewDatabaseAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAutomaticTuningClient { + return DatabaseAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database's automatic tuning. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the +// database. +func (client DatabaseAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAutomaticTuning, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAutomaticTuningClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAutomaticTuningClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAutomaticTuningClient) GetResponder(resp *http.Response) (result DatabaseAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning properties for target database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of the +// database. parameters is the requested automatic tuning resource state. +func (client DatabaseAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAutomaticTuning) (result DatabaseAutomaticTuning, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseAutomaticTuningClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAutomaticTuning) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAutomaticTuningClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseAutomaticTuningClient) UpdateResponder(resp *http.Response) (result DatabaseAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobagents.go b/services/sql/mgmt/2017-03-01-preview/sql/jobagents.go new file mode 100644 index 000000000000..5f0edbacbd91 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobagents.go @@ -0,0 +1,430 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobAgentsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type JobAgentsClient struct { + BaseClient +} + +// NewJobAgentsClient creates an instance of the JobAgentsClient client. +func NewJobAgentsClient(subscriptionID string) JobAgentsClient { + return NewJobAgentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobAgentsClientWithBaseURI creates an instance of the JobAgentsClient client. +func NewJobAgentsClientWithBaseURI(baseURI string, subscriptionID string) JobAgentsClient { + return JobAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent to be created or updated. parameters is the requested job agent resource state. +func (client JobAgentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgent) (result JobAgentsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobAgentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobAgentProperties.DatabaseID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "sql.JobAgentsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobAgentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgent) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) CreateOrUpdateSender(req *http.Request) (future JobAgentsCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result JobAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent to be deleted. +func (client JobAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobAgentsDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobAgentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) DeleteSender(req *http.Request) (future JobAgentsDeleteFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent to be retrieved. +func (client JobAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobAgent, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobAgentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) GetResponder(resp *http.Response) (result JobAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of job agents in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. +func (client JobAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result JobAgentListResultPage, err error) { + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.jalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.jalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client JobAgentsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) ListByServerResponder(resp *http.Response) (result JobAgentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client JobAgentsClient) listByServerNextResults(lastResults JobAgentListResult) (result JobAgentListResult, err error) { + req, err := lastResults.jobAgentListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobAgentsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobAgentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobAgentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result JobAgentListResultIterator, err error) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a job agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent to be updated. parameters is the update to the job agent. +func (client JobAgentsClient) Update(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgentUpdate) (result JobAgentsUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client JobAgentsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgentUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) UpdateSender(req *http.Request) (future JobAgentsUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) UpdateResponder(resp *http.Response) (result JobAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobcredentials.go b/services/sql/mgmt/2017-03-01-preview/sql/jobcredentials.go new file mode 100644 index 000000000000..362e358dfff9 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobcredentials.go @@ -0,0 +1,360 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobCredentialsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobCredentialsClient struct { + BaseClient +} + +// NewJobCredentialsClient creates an instance of the JobCredentialsClient client. +func NewJobCredentialsClient(subscriptionID string) JobCredentialsClient { + return NewJobCredentialsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobCredentialsClientWithBaseURI creates an instance of the JobCredentialsClient client. +func NewJobCredentialsClientWithBaseURI(baseURI string, subscriptionID string) JobCredentialsClient { + return JobCredentialsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job credential. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. credentialName is the name of the credential. parameters is the requested job credential state. +func (client JobCredentialsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string, parameters JobCredential) (result JobCredential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobCredentialProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobCredentialProperties.Username", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobCredentialProperties.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "sql.JobCredentialsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobCredentialsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string, parameters JobCredential) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "credentialName": autorest.Encode("path", credentialName), + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) CreateOrUpdateResponder(resp *http.Response) (result JobCredential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job credential. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. credentialName is the name of the credential. +func (client JobCredentialsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobCredentialsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "credentialName": autorest.Encode("path", credentialName), + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a jobs credential. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. credentialName is the name of the credential. +func (client JobCredentialsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result JobCredential, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobCredentialsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "credentialName": autorest.Encode("path", credentialName), + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) GetResponder(resp *http.Response) (result JobCredential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets a list of jobs credentials. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. +func (client JobCredentialsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobCredentialListResultPage, err error) { + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jclr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "ListByAgent", resp, "Failure responding to request") + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobCredentialsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) ListByAgentResponder(resp *http.Response) (result JobCredentialListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobCredentialsClient) listByAgentNextResults(lastResults JobCredentialListResult) (result JobCredentialListResult, err error) { + req, err := lastResults.jobCredentialListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobCredentialsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobCredentialListResultIterator, err error) { + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobexecutions.go b/services/sql/mgmt/2017-03-01-preview/sql/jobexecutions.go new file mode 100644 index 000000000000..9579b83624c4 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobexecutions.go @@ -0,0 +1,531 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/satori/go.uuid" + "net/http" +) + +// JobExecutionsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobExecutionsClient struct { + BaseClient +} + +// NewJobExecutionsClient creates an instance of the JobExecutionsClient client. +func NewJobExecutionsClient(subscriptionID string) JobExecutionsClient { + return NewJobExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobExecutionsClientWithBaseURI creates an instance of the JobExecutionsClient client. +func NewJobExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobExecutionsClient { + return JobExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel requests cancellation of a job execution. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. jobExecutionID is the id of the job execution to cancel. +func (client JobExecutionsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result autorest.Response, err error) { + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Cancel", resp, "Failure responding to request") + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client JobExecutionsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) CancelSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create starts an elastic job execution. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. +func (client JobExecutionsClient) Create(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobExecutionsCreateFuture, err error) { + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobExecutionsClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) CreateSender(req *http.Request) (future JobExecutionsCreateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) CreateResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updatess a job execution. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. jobExecutionID is the job execution id to create the job execution +// under. +func (client JobExecutionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result JobExecutionsCreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobExecutionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) CreateOrUpdateSender(req *http.Request) (future JobExecutionsCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) CreateOrUpdateResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a job execution. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. jobExecutionID is the id of the job execution +func (client JobExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result JobExecution, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent lists all executions in a job agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. skip is the number of elements in the collection to skip. +func (client JobExecutionsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, skip string) (result JobExecutionListResultPage, err error) { + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByAgent", resp, "Failure responding to request") + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobExecutionsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, skip string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skip) > 0 { + queryParameters["$skip"] = autorest.Encode("query", skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) ListByAgentResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobExecutionsClient) listByAgentNextResults(lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobExecutionsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, skip string) (result JobExecutionListResultIterator, err error) { + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName, skip) + return +} + +// ListByJob lists a job's executions. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. skip is the number of elements in the collection to skip. +func (client JobExecutionsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, skip string) (result JobExecutionListResultPage, err error) { + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobExecutionsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, skip string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skip) > 0 { + queryParameters["$skip"] = autorest.Encode("query", skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) ListByJobResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobExecutionsClient) listByJobNextResults(lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobExecutionsClient) ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, skip string) (result JobExecutionListResultIterator, err error) { + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName, skip) + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobs.go b/services/sql/mgmt/2017-03-01-preview/sql/jobs.go new file mode 100644 index 000000000000..bce1d965fdde --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobs.go @@ -0,0 +1,350 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// JobsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact with +// Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete +// databases. +type JobsClient struct { + BaseClient +} + +// NewJobsClient creates an instance of the JobsClient client. +func NewJobsClient(subscriptionID string) JobsClient { + return NewJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobsClientWithBaseURI creates an instance of the JobsClient client. +func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient { + return JobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. parameters is the requested job state. +func (client JobsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, parameters Job) (result Job, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, parameters Job) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobsClient) CreateOrUpdateResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to delete. +func (client JobsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. +func (client JobsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result Job, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobsClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets a list of jobs. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. +func (client JobsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobListResultPage, err error) { + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jlr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "ListByAgent", resp, "Failure responding to request") + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobsClient) ListByAgentResponder(resp *http.Response) (result JobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobsClient) listByAgentNextResults(lastResults JobListResult) (result JobListResult, err error) { + req, err := lastResults.jobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobListResultIterator, err error) { + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobsteps.go b/services/sql/mgmt/2017-03-01-preview/sql/jobsteps.go new file mode 100644 index 000000000000..bc948fdff1a0 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobsteps.go @@ -0,0 +1,545 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobStepsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type JobStepsClient struct { + BaseClient +} + +// NewJobStepsClient creates an instance of the JobStepsClient client. +func NewJobStepsClient(subscriptionID string) JobStepsClient { + return NewJobStepsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobStepsClientWithBaseURI creates an instance of the JobStepsClient client. +func NewJobStepsClientWithBaseURI(baseURI string, subscriptionID string) JobStepsClient { + return JobStepsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job step. This will implicitly create a new job version. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. stepName is the name of the job step. parameters is the requested state of +// the job step. +func (client JobStepsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string, parameters JobStep) (result JobStep, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobStepProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobStepProperties.TargetGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Credential", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Action", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobStepProperties.Action.Value", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.JobStepProperties.Output", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobStepProperties.Output.Server", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.Database", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.Table", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.Credential", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "sql.JobStepsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobStepsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string, parameters JobStep) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobStepsClient) CreateOrUpdateResponder(resp *http.Response) (result JobStep, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job step. This will implicitly create a new job version. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. stepName is the name of the job step to delete. +func (client JobStepsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobStepsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobStepsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job step in a job's current version. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. stepName is the name of the job step. +func (client JobStepsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result JobStep, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStepsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStepsClient) GetResponder(resp *http.Response) (result JobStep, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByVersion gets the specified version of a job step. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. jobVersion is the version of the job to get. stepName is the name of the job +// step. +func (client JobStepsClient) GetByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32, stepName string) (result JobStep, err error) { + req, err := client.GetByVersionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "GetByVersion", nil, "Failure preparing request") + return + } + + resp, err := client.GetByVersionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "GetByVersion", resp, "Failure sending request") + return + } + + result, err = client.GetByVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "GetByVersion", resp, "Failure responding to request") + } + + return +} + +// GetByVersionPreparer prepares the GetByVersion request. +func (client JobStepsClient) GetByVersionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "jobVersion": autorest.Encode("path", jobVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByVersionSender sends the GetByVersion request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) GetByVersionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByVersionResponder handles the response to the GetByVersion request. The method always +// closes the http.Response Body. +func (client JobStepsClient) GetByVersionResponder(resp *http.Response) (result JobStep, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob gets all job steps for a job's current version. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. +func (client JobStepsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobStepListResultPage, err error) { + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobStepsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobStepsClient) ListByJobResponder(resp *http.Response) (result JobStepListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobStepsClient) listByJobNextResults(lastResults JobStepListResult) (result JobStepListResult, err error) { + req, err := lastResults.jobStepListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStepsClient) ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobStepListResultIterator, err error) { + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName) + return +} + +// ListByVersion gets all job steps in the specified job version. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. jobVersion is the version of the job to get. +func (client JobStepsClient) ListByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result JobStepListResultPage, err error) { + result.fn = client.listByVersionNextResults + req, err := client.ListByVersionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByVersion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByVersionSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByVersion", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByVersion", resp, "Failure responding to request") + } + + return +} + +// ListByVersionPreparer prepares the ListByVersion request. +func (client JobStepsClient) ListByVersionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "jobVersion": autorest.Encode("path", jobVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByVersionSender sends the ListByVersion request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) ListByVersionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByVersionResponder handles the response to the ListByVersion request. The method always +// closes the http.Response Body. +func (client JobStepsClient) ListByVersionResponder(resp *http.Response) (result JobStepListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByVersionNextResults retrieves the next set of results, if any. +func (client JobStepsClient) listByVersionNextResults(lastResults JobStepListResult) (result JobStepListResult, err error) { + req, err := lastResults.jobStepListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByVersionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByVersionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByVersionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByVersionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByVersionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStepsClient) ListByVersionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result JobStepListResultIterator, err error) { + result.page, err = client.ListByVersion(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobtargetgroups.go b/services/sql/mgmt/2017-03-01-preview/sql/jobtargetgroups.go new file mode 100644 index 000000000000..09186cccaaf5 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobtargetgroups.go @@ -0,0 +1,358 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobTargetGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobTargetGroupsClient struct { + BaseClient +} + +// NewJobTargetGroupsClient creates an instance of the JobTargetGroupsClient client. +func NewJobTargetGroupsClient(subscriptionID string) JobTargetGroupsClient { + return NewJobTargetGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobTargetGroupsClientWithBaseURI creates an instance of the JobTargetGroupsClient client. +func NewJobTargetGroupsClientWithBaseURI(baseURI string, subscriptionID string) JobTargetGroupsClient { + return JobTargetGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a target group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. targetGroupName is the name of the target group. parameters is the requested state of the target group. +func (client JobTargetGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string, parameters JobTargetGroup) (result JobTargetGroup, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobTargetGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobTargetGroupProperties.Members", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, targetGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobTargetGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string, parameters JobTargetGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetGroupName": autorest.Encode("path", targetGroupName), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result JobTargetGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a target group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. targetGroupName is the name of the target group. +func (client JobTargetGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, targetGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobTargetGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetGroupName": autorest.Encode("path", targetGroupName), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a target group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. targetGroupName is the name of the target group. +func (client JobTargetGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result JobTargetGroup, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, targetGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobTargetGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetGroupName": autorest.Encode("path", targetGroupName), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) GetResponder(resp *http.Response) (result JobTargetGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets all target groups in an agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. +func (client JobTargetGroupsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobTargetGroupListResultPage, err error) { + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jtglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jtglr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "ListByAgent", resp, "Failure responding to request") + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobTargetGroupsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) ListByAgentResponder(resp *http.Response) (result JobTargetGroupListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobTargetGroupsClient) listByAgentNextResults(lastResults JobTargetGroupListResult) (result JobTargetGroupListResult, err error) { + req, err := lastResults.jobTargetGroupListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobTargetGroupsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobTargetGroupListResultIterator, err error) { + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/jobversions.go b/services/sql/mgmt/2017-03-01-preview/sql/jobversions.go new file mode 100644 index 000000000000..f6f15be257b5 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/jobversions.go @@ -0,0 +1,211 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// JobVersionsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type JobVersionsClient struct { + BaseClient +} + +// NewJobVersionsClient creates an instance of the JobVersionsClient client. +func NewJobVersionsClient(subscriptionID string) JobVersionsClient { + return NewJobVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobVersionsClientWithBaseURI creates an instance of the JobVersionsClient client. +func NewJobVersionsClientWithBaseURI(baseURI string, subscriptionID string) JobVersionsClient { + return JobVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a job version. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job. jobVersion is the version of the job to get. +func (client JobVersionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result JobVersion, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobVersionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "jobVersion": autorest.Encode("path", jobVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobVersionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobVersionsClient) GetResponder(resp *http.Response) (result JobVersion, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob gets all versions of a job. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. jobAgentName is the name of the job +// agent. jobName is the name of the job to get. +func (client JobVersionsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobVersionListResultPage, err error) { + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jvlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jvlr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "ListByJob", resp, "Failure responding to request") + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobVersionsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobVersionsClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobVersionsClient) ListByJobResponder(resp *http.Response) (result JobVersionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobVersionsClient) listByJobNextResults(lastResults JobVersionListResult) (result JobVersionListResult, err error) { + req, err := lastResults.jobVersionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobVersionsClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobVersionsClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobVersionsClient) ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobVersionListResultIterator, err error) { + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName) + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/models.go b/services/sql/mgmt/2017-03-01-preview/sql/models.go index 2631b9113d61..1d3d2bb83ac5 100644 --- a/services/sql/mgmt/2017-03-01-preview/sql/models.go +++ b/services/sql/mgmt/2017-03-01-preview/sql/models.go @@ -37,14 +37,94 @@ const ( SQL AuthenticationType = "SQL" ) +// AutomaticTuningDisabledReason enumerates the values for automatic tuning disabled reason. +type AutomaticTuningDisabledReason string + +const ( + // AutoConfigured ... + AutoConfigured AutomaticTuningDisabledReason = "AutoConfigured" + // Default ... + Default AutomaticTuningDisabledReason = "Default" + // Disabled ... + Disabled AutomaticTuningDisabledReason = "Disabled" + // InheritedFromServer ... + InheritedFromServer AutomaticTuningDisabledReason = "InheritedFromServer" + // NotSupported ... + NotSupported AutomaticTuningDisabledReason = "NotSupported" + // QueryStoreOff ... + QueryStoreOff AutomaticTuningDisabledReason = "QueryStoreOff" + // QueryStoreReadOnly ... + QueryStoreReadOnly AutomaticTuningDisabledReason = "QueryStoreReadOnly" +) + +// AutomaticTuningMode enumerates the values for automatic tuning mode. +type AutomaticTuningMode string + +const ( + // Auto ... + Auto AutomaticTuningMode = "Auto" + // Custom ... + Custom AutomaticTuningMode = "Custom" + // Inherit ... + Inherit AutomaticTuningMode = "Inherit" + // Unspecified ... + Unspecified AutomaticTuningMode = "Unspecified" +) + +// AutomaticTuningOptionModeActual enumerates the values for automatic tuning option mode actual. +type AutomaticTuningOptionModeActual string + +const ( + // Off ... + Off AutomaticTuningOptionModeActual = "Off" + // On ... + On AutomaticTuningOptionModeActual = "On" +) + +// AutomaticTuningOptionModeDesired enumerates the values for automatic tuning option mode desired. +type AutomaticTuningOptionModeDesired string + +const ( + // AutomaticTuningOptionModeDesiredDefault ... + AutomaticTuningOptionModeDesiredDefault AutomaticTuningOptionModeDesired = "Default" + // AutomaticTuningOptionModeDesiredOff ... + AutomaticTuningOptionModeDesiredOff AutomaticTuningOptionModeDesired = "Off" + // AutomaticTuningOptionModeDesiredOn ... + AutomaticTuningOptionModeDesiredOn AutomaticTuningOptionModeDesired = "On" +) + +// AutomaticTuningServerMode enumerates the values for automatic tuning server mode. +type AutomaticTuningServerMode string + +const ( + // AutomaticTuningServerModeAuto ... + AutomaticTuningServerModeAuto AutomaticTuningServerMode = "Auto" + // AutomaticTuningServerModeCustom ... + AutomaticTuningServerModeCustom AutomaticTuningServerMode = "Custom" + // AutomaticTuningServerModeUnspecified ... + AutomaticTuningServerModeUnspecified AutomaticTuningServerMode = "Unspecified" +) + +// AutomaticTuningServerReason enumerates the values for automatic tuning server reason. +type AutomaticTuningServerReason string + +const ( + // AutomaticTuningServerReasonAutoConfigured ... + AutomaticTuningServerReasonAutoConfigured AutomaticTuningServerReason = "AutoConfigured" + // AutomaticTuningServerReasonDefault ... + AutomaticTuningServerReasonDefault AutomaticTuningServerReason = "Default" + // AutomaticTuningServerReasonDisabled ... + AutomaticTuningServerReasonDisabled AutomaticTuningServerReason = "Disabled" +) + // BackupLongTermRetentionPolicyState enumerates the values for backup long term retention policy state. type BackupLongTermRetentionPolicyState string const ( - // Disabled ... - Disabled BackupLongTermRetentionPolicyState = "Disabled" - // Enabled ... - Enabled BackupLongTermRetentionPolicyState = "Enabled" + // BackupLongTermRetentionPolicyStateDisabled ... + BackupLongTermRetentionPolicyStateDisabled BackupLongTermRetentionPolicyState = "Disabled" + // BackupLongTermRetentionPolicyStateEnabled ... + BackupLongTermRetentionPolicyStateEnabled BackupLongTermRetentionPolicyState = "Enabled" ) // BlobAuditingPolicyState enumerates the values for blob auditing policy state. @@ -85,22 +165,22 @@ const ( type CreateMode string const ( - // Copy ... - Copy CreateMode = "Copy" - // Default ... - Default CreateMode = "Default" - // NonReadableSecondary ... - NonReadableSecondary CreateMode = "NonReadableSecondary" - // OnlineSecondary ... - OnlineSecondary CreateMode = "OnlineSecondary" - // PointInTimeRestore ... - PointInTimeRestore CreateMode = "PointInTimeRestore" - // Recovery ... - Recovery CreateMode = "Recovery" - // Restore ... - Restore CreateMode = "Restore" - // RestoreLongTermRetentionBackup ... - RestoreLongTermRetentionBackup CreateMode = "RestoreLongTermRetentionBackup" + // CreateModeCopy ... + CreateModeCopy CreateMode = "Copy" + // CreateModeDefault ... + CreateModeDefault CreateMode = "Default" + // CreateModeNonReadableSecondary ... + CreateModeNonReadableSecondary CreateMode = "NonReadableSecondary" + // CreateModeOnlineSecondary ... + CreateModeOnlineSecondary CreateMode = "OnlineSecondary" + // CreateModePointInTimeRestore ... + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeRecovery ... + CreateModeRecovery CreateMode = "Recovery" + // CreateModeRestore ... + CreateModeRestore CreateMode = "Restore" + // CreateModeRestoreLongTermRetentionBackup ... + CreateModeRestoreLongTermRetentionBackup CreateMode = "RestoreLongTermRetentionBackup" ) // DatabaseEdition enumerates the values for database edition. @@ -221,22 +301,108 @@ const ( SystemAssigned IdentityType = "SystemAssigned" ) -// ManagementOperationState enumerates the values for management operation state. -type ManagementOperationState string +// JobExecutionLifecycle enumerates the values for job execution lifecycle. +type JobExecutionLifecycle string const ( - // CancelInProgress ... - CancelInProgress ManagementOperationState = "CancelInProgress" - // Cancelled ... - Cancelled ManagementOperationState = "Cancelled" + // Canceled ... + Canceled JobExecutionLifecycle = "Canceled" + // Created ... + Created JobExecutionLifecycle = "Created" // Failed ... - Failed ManagementOperationState = "Failed" + Failed JobExecutionLifecycle = "Failed" // InProgress ... - InProgress ManagementOperationState = "InProgress" - // Pending ... - Pending ManagementOperationState = "Pending" + InProgress JobExecutionLifecycle = "InProgress" + // Skipped ... + Skipped JobExecutionLifecycle = "Skipped" // Succeeded ... - Succeeded ManagementOperationState = "Succeeded" + Succeeded JobExecutionLifecycle = "Succeeded" + // SucceededWithSkipped ... + SucceededWithSkipped JobExecutionLifecycle = "SucceededWithSkipped" + // TimedOut ... + TimedOut JobExecutionLifecycle = "TimedOut" + // WaitingForChildJobExecutions ... + WaitingForChildJobExecutions JobExecutionLifecycle = "WaitingForChildJobExecutions" + // WaitingForRetry ... + WaitingForRetry JobExecutionLifecycle = "WaitingForRetry" +) + +// JobScheduleType enumerates the values for job schedule type. +type JobScheduleType string + +const ( + // Once ... + Once JobScheduleType = "Once" + // Recurring ... + Recurring JobScheduleType = "Recurring" +) + +// JobStepActionSource enumerates the values for job step action source. +type JobStepActionSource string + +const ( + // Inline ... + Inline JobStepActionSource = "Inline" +) + +// JobStepActionType enumerates the values for job step action type. +type JobStepActionType string + +const ( + // TSQL ... + TSQL JobStepActionType = "TSql" +) + +// JobStepOutputType enumerates the values for job step output type. +type JobStepOutputType string + +const ( + // SQLDatabase ... + SQLDatabase JobStepOutputType = "SqlDatabase" +) + +// JobTargetGroupMembershipType enumerates the values for job target group membership type. +type JobTargetGroupMembershipType string + +const ( + // Exclude ... + Exclude JobTargetGroupMembershipType = "Exclude" + // Include ... + Include JobTargetGroupMembershipType = "Include" +) + +// JobTargetType enumerates the values for job target type. +type JobTargetType string + +const ( + // JobTargetTypeSQLDatabase ... + JobTargetTypeSQLDatabase JobTargetType = "SqlDatabase" + // JobTargetTypeSQLElasticPool ... + JobTargetTypeSQLElasticPool JobTargetType = "SqlElasticPool" + // JobTargetTypeSQLServer ... + JobTargetTypeSQLServer JobTargetType = "SqlServer" + // JobTargetTypeSQLShardMap ... + JobTargetTypeSQLShardMap JobTargetType = "SqlShardMap" + // JobTargetTypeTargetGroup ... + JobTargetTypeTargetGroup JobTargetType = "TargetGroup" +) + +// ManagementOperationState enumerates the values for management operation state. +type ManagementOperationState string + +const ( + // ManagementOperationStateCancelInProgress ... + ManagementOperationStateCancelInProgress ManagementOperationState = "CancelInProgress" + // ManagementOperationStateCancelled ... + ManagementOperationStateCancelled ManagementOperationState = "Cancelled" + // ManagementOperationStateFailed ... + ManagementOperationStateFailed ManagementOperationState = "Failed" + // ManagementOperationStateInProgress ... + ManagementOperationStateInProgress ManagementOperationState = "InProgress" + // ManagementOperationStatePending ... + ManagementOperationStatePending ManagementOperationState = "Pending" + // ManagementOperationStateSucceeded ... + ManagementOperationStateSucceeded ManagementOperationState = "Succeeded" ) // MaxSizeUnits enumerates the values for max size units. @@ -289,6 +455,22 @@ const ( Total PrimaryAggregationType = "Total" ) +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreated ... + ProvisioningStateCreated ProvisioningState = "Created" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateInProgress ... + ProvisioningStateInProgress ProvisioningState = "InProgress" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + // ReadOnlyEndpointFailoverPolicy enumerates the values for read only endpoint failover policy. type ReadOnlyEndpointFailoverPolicy string @@ -335,28 +517,28 @@ const ( type RecommendedIndexState string const ( - // RecommendedIndexStateActive ... - RecommendedIndexStateActive RecommendedIndexState = "Active" - // RecommendedIndexStateBlocked ... - RecommendedIndexStateBlocked RecommendedIndexState = "Blocked" - // RecommendedIndexStateExecuting ... - RecommendedIndexStateExecuting RecommendedIndexState = "Executing" - // RecommendedIndexStateExpired ... - RecommendedIndexStateExpired RecommendedIndexState = "Expired" - // RecommendedIndexStateIgnored ... - RecommendedIndexStateIgnored RecommendedIndexState = "Ignored" - // RecommendedIndexStatePending ... - RecommendedIndexStatePending RecommendedIndexState = "Pending" - // RecommendedIndexStatePendingRevert ... - RecommendedIndexStatePendingRevert RecommendedIndexState = "Pending Revert" - // RecommendedIndexStateReverted ... - RecommendedIndexStateReverted RecommendedIndexState = "Reverted" - // RecommendedIndexStateReverting ... - RecommendedIndexStateReverting RecommendedIndexState = "Reverting" - // RecommendedIndexStateSuccess ... - RecommendedIndexStateSuccess RecommendedIndexState = "Success" - // RecommendedIndexStateVerifying ... - RecommendedIndexStateVerifying RecommendedIndexState = "Verifying" + // Active ... + Active RecommendedIndexState = "Active" + // Blocked ... + Blocked RecommendedIndexState = "Blocked" + // Executing ... + Executing RecommendedIndexState = "Executing" + // Expired ... + Expired RecommendedIndexState = "Expired" + // Ignored ... + Ignored RecommendedIndexState = "Ignored" + // Pending ... + Pending RecommendedIndexState = "Pending" + // PendingRevert ... + PendingRevert RecommendedIndexState = "Pending Revert" + // Reverted ... + Reverted RecommendedIndexState = "Reverted" + // Reverting ... + Reverting RecommendedIndexState = "Reverting" + // Success ... + Success RecommendedIndexState = "Success" + // Verifying ... + Verifying RecommendedIndexState = "Verifying" ) // RecommendedIndexType enumerates the values for recommended index type. @@ -659,30 +841,30 @@ const ( type SyncGroupLogType string const ( - // All ... - All SyncGroupLogType = "All" - // Error ... - Error SyncGroupLogType = "Error" - // Success ... - Success SyncGroupLogType = "Success" - // Warning ... - Warning SyncGroupLogType = "Warning" + // SyncGroupLogTypeAll ... + SyncGroupLogTypeAll SyncGroupLogType = "All" + // SyncGroupLogTypeError ... + SyncGroupLogTypeError SyncGroupLogType = "Error" + // SyncGroupLogTypeSuccess ... + SyncGroupLogTypeSuccess SyncGroupLogType = "Success" + // SyncGroupLogTypeWarning ... + SyncGroupLogTypeWarning SyncGroupLogType = "Warning" ) // SyncGroupState enumerates the values for sync group state. type SyncGroupState string const ( - // SyncGroupStateError ... - SyncGroupStateError SyncGroupState = "Error" - // SyncGroupStateGood ... - SyncGroupStateGood SyncGroupState = "Good" - // SyncGroupStateNotReady ... - SyncGroupStateNotReady SyncGroupState = "NotReady" - // SyncGroupStateProgressing ... - SyncGroupStateProgressing SyncGroupState = "Progressing" - // SyncGroupStateWarning ... - SyncGroupStateWarning SyncGroupState = "Warning" + // Error ... + Error SyncGroupState = "Error" + // Good ... + Good SyncGroupState = "Good" + // NotReady ... + NotReady SyncGroupState = "NotReady" + // Progressing ... + Progressing SyncGroupState = "Progressing" + // Warning ... + Warning SyncGroupState = "Warning" ) // SyncMemberDbType enumerates the values for sync member db type. @@ -809,6 +991,40 @@ const ( VirtualNetworkRuleStateUnknown VirtualNetworkRuleState = "Unknown" ) +// AutomaticTuningOptions automatic tuning properties for individual advisors. +type AutomaticTuningOptions struct { + // DesiredState - Automatic tuning option desired state. Possible values include: 'AutomaticTuningOptionModeDesiredOff', 'AutomaticTuningOptionModeDesiredOn', 'AutomaticTuningOptionModeDesiredDefault' + DesiredState AutomaticTuningOptionModeDesired `json:"desiredState,omitempty"` + // ActualState - Automatic tuning option actual state. Possible values include: 'Off', 'On' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - Reason description if desired and actual state are different. Possible values include: 'Default', 'Disabled', 'AutoConfigured', 'InheritedFromServer', 'QueryStoreOff', 'QueryStoreReadOnly', 'NotSupported' + ReasonDesc AutomaticTuningDisabledReason `json:"reasonDesc,omitempty"` +} + +// AutomaticTuningServerOptions automatic tuning properties for individual advisors. +type AutomaticTuningServerOptions struct { + // DesiredState - Automatic tuning option desired state. Possible values include: 'AutomaticTuningOptionModeDesiredOff', 'AutomaticTuningOptionModeDesiredOn', 'AutomaticTuningOptionModeDesiredDefault' + DesiredState AutomaticTuningOptionModeDesired `json:"desiredState,omitempty"` + // ActualState - Automatic tuning option actual state. Possible values include: 'Off', 'On' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - Reason description if desired and actual state are different. Possible values include: 'AutomaticTuningServerReasonDefault', 'AutomaticTuningServerReasonDisabled', 'AutomaticTuningServerReasonAutoConfigured' + ReasonDesc AutomaticTuningServerReason `json:"reasonDesc,omitempty"` +} + +// AutomaticTuningServerProperties server-level Automatic Tuning properties. +type AutomaticTuningServerProperties struct { + // DesiredState - Automatic tuning desired state. Possible values include: 'AutomaticTuningServerModeCustom', 'AutomaticTuningServerModeAuto', 'AutomaticTuningServerModeUnspecified' + DesiredState AutomaticTuningServerMode `json:"desiredState,omitempty"` + // ActualState - Automatic tuning actual state. Possible values include: 'AutomaticTuningServerModeCustom', 'AutomaticTuningServerModeAuto', 'AutomaticTuningServerModeUnspecified' + ActualState AutomaticTuningServerMode `json:"actualState,omitempty"` + // Options - Automatic tuning options definition. + Options *map[string]*AutomaticTuningServerOptions `json:"options,omitempty"` +} + // BackupLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a // long-running operation. type BackupLongTermRetentionPoliciesCreateOrUpdateFuture struct { @@ -822,22 +1038,30 @@ func (future BackupLongTermRetentionPoliciesCreateOrUpdateFuture) Result(client var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return bltrp, autorest.NewError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return bltrp, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { bltrp, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } bltrp, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -927,7 +1151,7 @@ type BackupLongTermRetentionPolicyListResult struct { // BackupLongTermRetentionPolicyProperties the properties of a backup long term retention policy type BackupLongTermRetentionPolicyProperties struct { - // State - The status of the backup long term retention policy. Possible values include: 'Disabled', 'Enabled' + // State - The status of the backup long term retention policy. Possible values include: 'BackupLongTermRetentionPolicyStateDisabled', 'BackupLongTermRetentionPolicyStateEnabled' State BackupLongTermRetentionPolicyState `json:"state,omitempty"` // RecoveryServicesBackupPolicyResourceID - The azure recovery services backup protection policy resource id RecoveryServicesBackupPolicyResourceID *string `json:"recoveryServicesBackupPolicyResourceId,omitempty"` @@ -1036,22 +1260,30 @@ func (future BackupLongTermRetentionVaultsCreateOrUpdateFuture) Result(client Ba var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return bltrv, autorest.NewError("sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return bltrv, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { bltrv, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } bltrv, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1177,6 +1409,81 @@ func (d *Database) UnmarshalJSON(body []byte) error { return nil } +// DatabaseAutomaticTuning database-level Automatic Tuning. +type DatabaseAutomaticTuning struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // DatabaseAutomaticTuningProperties - Resource properties. + *DatabaseAutomaticTuningProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAutomaticTuning struct. +func (dat *DatabaseAutomaticTuning) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties DatabaseAutomaticTuningProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + dat.DatabaseAutomaticTuningProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + dat.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + dat.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + dat.Type = &typeVar + } + + return nil +} + +// DatabaseAutomaticTuningProperties database-level Automatic Tuning properties. +type DatabaseAutomaticTuningProperties struct { + // DesiredState - Automatic tuning desired state. Possible values include: 'Inherit', 'Custom', 'Auto', 'Unspecified' + DesiredState AutomaticTuningMode `json:"desiredState,omitempty"` + // ActualState - Automatic tuning actual state. Possible values include: 'Inherit', 'Custom', 'Auto', 'Unspecified' + ActualState AutomaticTuningMode `json:"actualState,omitempty"` + // Options - Automatic tuning options definition. + Options *map[string]*AutomaticTuningOptions `json:"options,omitempty"` +} + // DatabaseBlobAuditingPolicy a database blob auditing policy. type DatabaseBlobAuditingPolicy struct { autorest.Response `json:"-"` @@ -1459,7 +1766,7 @@ type DatabaseOperationProperties struct { ServerName *string `json:"serverName,omitempty"` // StartTime - The operation start time. StartTime *date.Time `json:"startTime,omitempty"` - // State - The operation state. Possible values include: 'Pending', 'InProgress', 'Succeeded', 'Failed', 'CancelInProgress', 'Cancelled' + // State - The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' State ManagementOperationState `json:"state,omitempty"` // ErrorCode - The operation error code. ErrorCode *int32 `json:"errorCode,omitempty"` @@ -1493,7 +1800,7 @@ type DatabaseProperties struct { // Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore. // Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time. // RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID. - // Copy, NonReadableSecondary, OnlineSecondary and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'Copy', 'Default', 'NonReadableSecondary', 'OnlineSecondary', 'PointInTimeRestore', 'Recovery', 'Restore', 'RestoreLongTermRetentionBackup' + // Copy, NonReadableSecondary, OnlineSecondary and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'CreateModeCopy', 'CreateModeDefault', 'CreateModeNonReadableSecondary', 'CreateModeOnlineSecondary', 'CreateModePointInTimeRestore', 'CreateModeRecovery', 'CreateModeRestore', 'CreateModeRestoreLongTermRetentionBackup' CreateMode CreateMode `json:"createMode,omitempty"` // SourceDatabaseID - Conditional. If createMode is Copy, NonReadableSecondary, OnlineSecondary, PointInTimeRestore, Recovery, or Restore, then this value is required. Specifies the resource ID of the source database. If createMode is NonReadableSecondary or OnlineSecondary, the name of the source database must be the same as the new database being created. SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` @@ -1548,22 +1855,30 @@ func (future DatabasesCreateImportOperationFuture) Result(client DatabasesClient var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesCreateImportOperationFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateImportOperationFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.CreateImportOperationResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure sending request") return } ier, err = client.CreateImportOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure responding to request") + } return } @@ -1579,22 +1894,30 @@ func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Da var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return d, autorest.NewError("sql.DatabasesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { d, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } d, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -1719,22 +2042,30 @@ func (future DatabasesExportFuture) Result(client DatabasesClient) (ier ImportEx var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesExportFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.ExportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure sending request") return } ier, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure responding to request") + } return } @@ -1750,22 +2081,30 @@ func (future DatabasesImportFuture) Result(client DatabasesClient) (ier ImportEx var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ier, autorest.NewError("sql.DatabasesImportFuture", "Result", "asynchronous operation has not completed") + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") } if future.PollingMethod() == azure.PollingLocation { ier, err = client.ImportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure sending request") return } ier, err = client.ImportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure responding to request") + } return } @@ -1781,22 +2120,30 @@ func (future DatabasesPauseFuture) Result(client DatabasesClient) (ar autorest.R var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.DatabasesPauseFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.PauseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure sending request") return } ar, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure responding to request") + } return } @@ -1812,22 +2159,30 @@ func (future DatabasesResumeFuture) Result(client DatabasesClient) (ar autorest. var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.DatabasesResumeFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.ResumeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure sending request") return } ar, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure responding to request") + } return } @@ -1843,22 +2198,30 @@ func (future DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return d, autorest.NewError("sql.DatabasesUpdateFuture", "Result", "asynchronous operation has not completed") + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { d, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure sending request") return } d, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2633,22 +2996,30 @@ func (future ElasticPoolsCreateOrUpdateFuture) Result(client ElasticPoolsClient) var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.ElasticPoolsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2664,22 +3035,30 @@ func (future ElasticPoolsUpdateFuture) Result(client ElasticPoolsClient) (ep Ela var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.ElasticPoolsUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -2977,22 +3356,30 @@ func (future EncryptionProtectorsCreateOrUpdateFuture) Result(client EncryptionP var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ep, autorest.NewError("sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return ep, azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -3246,22 +3633,30 @@ func (future FailoverGroupsCreateOrUpdateFuture) Result(client FailoverGroupsCli var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } fg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -3277,22 +3672,30 @@ func (future FailoverGroupsDeleteFuture) Result(client FailoverGroupsClient) (ar var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.FailoverGroupsDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -3308,22 +3711,30 @@ func (future FailoverGroupsFailoverFuture) Result(client FailoverGroupsClient) ( var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsFailoverFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure sending request") return } fg, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure responding to request") + } return } @@ -3340,22 +3751,30 @@ func (future FailoverGroupsForceFailoverAllowDataLossFuture) Result(client Failo var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.ForceFailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") return } fg, err = client.ForceFailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } return } @@ -3371,22 +3790,30 @@ func (future FailoverGroupsUpdateFuture) Result(client FailoverGroupsClient) (fg var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return fg, autorest.NewError("sql.FailoverGroupsUpdateFuture", "Result", "asynchronous operation has not completed") + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { fg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure sending request") return } fg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -3763,70 +4190,1574 @@ type ImportExtensionRequest struct { *ImportExtensionProperties `json:"properties,omitempty"` } -// UnmarshalJSON is the custom unmarshaler for ImportExtensionRequest struct. -func (ier *ImportExtensionRequest) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// UnmarshalJSON is the custom unmarshaler for ImportExtensionRequest struct. +func (ier *ImportExtensionRequest) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + ier.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + ier.Type = &typeVar + } + + v = m["properties"] + if v != nil { + var properties ImportExtensionProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + ier.ImportExtensionProperties = &properties + } + + return nil +} + +// ImportRequest import database parameters. +type ImportRequest struct { + // StorageKeyType - The type of the storage key to use. Possible values include: 'StorageAccessKey', 'SharedAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - The storage key to use. If storage key type is SharedAccessKey, it must be preceded with a "?." + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - The storage uri to use. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - The name of the SQL administrator. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The password of the SQL administrator. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - The authentication type. Possible values include: 'SQL', 'ADPassword' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DatabaseName - The name of the database to import. + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - The edition for the database being created. Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2' + Edition DatabaseEdition `json:"edition,omitempty"` + // ServiceObjectiveName - The name of the service objective to assign to the database. Possible values include: 'ServiceObjectiveNameSystem', 'ServiceObjectiveNameSystem0', 'ServiceObjectiveNameSystem1', 'ServiceObjectiveNameSystem2', 'ServiceObjectiveNameSystem3', 'ServiceObjectiveNameSystem4', 'ServiceObjectiveNameSystem2L', 'ServiceObjectiveNameSystem3L', 'ServiceObjectiveNameSystem4L', 'ServiceObjectiveNameFree', 'ServiceObjectiveNameBasic', 'ServiceObjectiveNameS0', 'ServiceObjectiveNameS1', 'ServiceObjectiveNameS2', 'ServiceObjectiveNameS3', 'ServiceObjectiveNameS4', 'ServiceObjectiveNameS6', 'ServiceObjectiveNameS7', 'ServiceObjectiveNameS9', 'ServiceObjectiveNameS12', 'ServiceObjectiveNameP1', 'ServiceObjectiveNameP2', 'ServiceObjectiveNameP3', 'ServiceObjectiveNameP4', 'ServiceObjectiveNameP6', 'ServiceObjectiveNameP11', 'ServiceObjectiveNameP15', 'ServiceObjectiveNamePRS1', 'ServiceObjectiveNamePRS2', 'ServiceObjectiveNamePRS4', 'ServiceObjectiveNamePRS6', 'ServiceObjectiveNameDW100', 'ServiceObjectiveNameDW200', 'ServiceObjectiveNameDW300', 'ServiceObjectiveNameDW400', 'ServiceObjectiveNameDW500', 'ServiceObjectiveNameDW600', 'ServiceObjectiveNameDW1000', 'ServiceObjectiveNameDW1200', 'ServiceObjectiveNameDW1000c', 'ServiceObjectiveNameDW1500', 'ServiceObjectiveNameDW1500c', 'ServiceObjectiveNameDW2000', 'ServiceObjectiveNameDW2000c', 'ServiceObjectiveNameDW3000', 'ServiceObjectiveNameDW2500c', 'ServiceObjectiveNameDW3000c', 'ServiceObjectiveNameDW6000', 'ServiceObjectiveNameDW5000c', 'ServiceObjectiveNameDW6000c', 'ServiceObjectiveNameDW7500c', 'ServiceObjectiveNameDW10000c', 'ServiceObjectiveNameDW15000c', 'ServiceObjectiveNameDW30000c', 'ServiceObjectiveNameDS100', 'ServiceObjectiveNameDS200', 'ServiceObjectiveNameDS300', 'ServiceObjectiveNameDS400', 'ServiceObjectiveNameDS500', 'ServiceObjectiveNameDS600', 'ServiceObjectiveNameDS1000', 'ServiceObjectiveNameDS1200', 'ServiceObjectiveNameDS1500', 'ServiceObjectiveNameDS2000', 'ServiceObjectiveNameElasticPool' + ServiceObjectiveName ServiceObjectiveName `json:"serviceObjectiveName,omitempty"` + // MaxSizeBytes - The maximum size for the newly imported database. + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` +} + +// Job a job. +type Job struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // JobProperties - Resource properties. + *JobProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for Job struct. +func (j *Job) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties JobProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + j.JobProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + j.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + j.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + j.Type = &typeVar + } + + return nil +} + +// JobAgent an Azure SQL job agent. +type JobAgent struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags *map[string]*string `json:"tags,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // JobAgentProperties - Resource properties. + *JobAgentProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for JobAgent struct. +func (ja *JobAgent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties JobAgentProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + ja.JobAgentProperties = &properties + } + + v = m["tags"] + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*m["tags"], &tags) + if err != nil { + return err + } + ja.Tags = &tags + } + + v = m["location"] + if v != nil { + var location string + err = json.Unmarshal(*m["location"], &location) + if err != nil { + return err + } + ja.Location = &location + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + ja.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + ja.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + ja.Type = &typeVar + } + + return nil +} + +// JobAgentListResult a list of Azure SQL job agents. +type JobAgentListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]JobAgent `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobAgentListResultIterator provides access to a complete listing of JobAgent values. +type JobAgentListResultIterator struct { + i int + page JobAgentListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobAgentListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobAgentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobAgentListResultIterator) Response() JobAgentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobAgentListResultIterator) Value() JobAgent { + if !iter.page.NotDone() { + return JobAgent{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jalr JobAgentListResult) IsEmpty() bool { + return jalr.Value == nil || len(*jalr.Value) == 0 +} + +// jobAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jalr JobAgentListResult) jobAgentListResultPreparer() (*http.Request, error) { + if jalr.NextLink == nil || len(to.String(jalr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jalr.NextLink))) +} + +// JobAgentListResultPage contains a page of JobAgent values. +type JobAgentListResultPage struct { + fn func(JobAgentListResult) (JobAgentListResult, error) + jalr JobAgentListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobAgentListResultPage) Next() error { + next, err := page.fn(page.jalr) + if err != nil { + return err + } + page.jalr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobAgentListResultPage) NotDone() bool { + return !page.jalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobAgentListResultPage) Response() JobAgentListResult { + return page.jalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobAgentListResultPage) Values() []JobAgent { + if page.jalr.IsEmpty() { + return nil + } + return *page.jalr.Value +} + +// JobAgentProperties properties of a job agent. +type JobAgentProperties struct { + // DatabaseID - Resource ID of the database to store job metadata in. + DatabaseID *string `json:"databaseId,omitempty"` +} + +// JobAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type JobAgentsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future JobAgentsCreateOrUpdateFuture) Result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ja, azure.NewAsyncOpIncompleteError("sql.JobAgentsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ja, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var resp *http.Response + resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ja, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// JobAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type JobAgentsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future JobAgentsDeleteFuture) Result(client JobAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.JobAgentsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var resp *http.Response + resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// JobAgentsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type JobAgentsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future JobAgentsUpdateFuture) Result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ja, azure.NewAsyncOpIncompleteError("sql.JobAgentsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ja, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var resp *http.Response + resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", resp, "Failure sending request") + return + } + ja, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// JobAgentUpdate an update to an Azure SQL job agent. +type JobAgentUpdate struct { + // Tags - Resource tags. + Tags *map[string]*string `json:"tags,omitempty"` +} + +// JobCredential a stored credential that can be used by a job to connect to target databases. +type JobCredential struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // JobCredentialProperties - Resource properties. + *JobCredentialProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for JobCredential struct. +func (jc *JobCredential) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties JobCredentialProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + jc.JobCredentialProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + jc.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + jc.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + jc.Type = &typeVar + } + + return nil +} + +// JobCredentialListResult a list of job credentials. +type JobCredentialListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]JobCredential `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobCredentialListResultIterator provides access to a complete listing of JobCredential values. +type JobCredentialListResultIterator struct { + i int + page JobCredentialListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobCredentialListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobCredentialListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobCredentialListResultIterator) Response() JobCredentialListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobCredentialListResultIterator) Value() JobCredential { + if !iter.page.NotDone() { + return JobCredential{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jclr JobCredentialListResult) IsEmpty() bool { + return jclr.Value == nil || len(*jclr.Value) == 0 +} + +// jobCredentialListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jclr JobCredentialListResult) jobCredentialListResultPreparer() (*http.Request, error) { + if jclr.NextLink == nil || len(to.String(jclr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jclr.NextLink))) +} + +// JobCredentialListResultPage contains a page of JobCredential values. +type JobCredentialListResultPage struct { + fn func(JobCredentialListResult) (JobCredentialListResult, error) + jclr JobCredentialListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobCredentialListResultPage) Next() error { + next, err := page.fn(page.jclr) + if err != nil { + return err + } + page.jclr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobCredentialListResultPage) NotDone() bool { + return !page.jclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobCredentialListResultPage) Response() JobCredentialListResult { + return page.jclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobCredentialListResultPage) Values() []JobCredential { + if page.jclr.IsEmpty() { + return nil + } + return *page.jclr.Value +} + +// JobCredentialProperties properties of a job credential. +type JobCredentialProperties struct { + // Username - The credential user name. + Username *string `json:"username,omitempty"` + // Password - The credential password. + Password *string `json:"password,omitempty"` +} + +// JobExecution an execution of a job +type JobExecution struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // JobExecutionProperties - Resource properties. + *JobExecutionProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for JobExecution struct. +func (je *JobExecution) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties JobExecutionProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + je.JobExecutionProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + je.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + je.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + je.Type = &typeVar + } + + return nil +} + +// JobExecutionListResult a list of job executions. +type JobExecutionListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]JobExecution `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobExecutionListResultIterator provides access to a complete listing of JobExecution values. +type JobExecutionListResultIterator struct { + i int + page JobExecutionListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobExecutionListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobExecutionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobExecutionListResultIterator) Response() JobExecutionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobExecutionListResultIterator) Value() JobExecution { + if !iter.page.NotDone() { + return JobExecution{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jelr JobExecutionListResult) IsEmpty() bool { + return jelr.Value == nil || len(*jelr.Value) == 0 +} + +// jobExecutionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jelr JobExecutionListResult) jobExecutionListResultPreparer() (*http.Request, error) { + if jelr.NextLink == nil || len(to.String(jelr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jelr.NextLink))) +} + +// JobExecutionListResultPage contains a page of JobExecution values. +type JobExecutionListResultPage struct { + fn func(JobExecutionListResult) (JobExecutionListResult, error) + jelr JobExecutionListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobExecutionListResultPage) Next() error { + next, err := page.fn(page.jelr) + if err != nil { + return err + } + page.jelr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobExecutionListResultPage) NotDone() bool { + return !page.jelr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobExecutionListResultPage) Response() JobExecutionListResult { + return page.jelr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobExecutionListResultPage) Values() []JobExecution { + if page.jelr.IsEmpty() { + return nil + } + return *page.jelr.Value +} + +// JobExecutionProperties properties for an Azure SQL Database Elastic job execution. +type JobExecutionProperties struct { + // JobVersion - The job version number. + JobVersion *int32 `json:"jobVersion,omitempty"` + // StepName - The job step name. + StepName *string `json:"stepName,omitempty"` + // StepID - The job step id. + StepID *int32 `json:"stepId,omitempty"` + // JobExecutionID - The unique identifier of the job execution. + JobExecutionID *uuid.UUID `json:"jobExecutionId,omitempty"` + // Lifecycle - The detailed state of the job execution. Possible values include: 'Created', 'InProgress', 'WaitingForChildJobExecutions', 'WaitingForRetry', 'Succeeded', 'SucceededWithSkipped', 'Failed', 'TimedOut', 'Canceled', 'Skipped' + Lifecycle JobExecutionLifecycle `json:"lifecycle,omitempty"` + // ProvisioningState - The ARM provisioning state of the job execution. Possible values include: 'ProvisioningStateCreated', 'ProvisioningStateInProgress', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // CreateTime - The time that the job execution was created. + CreateTime *date.Time `json:"createTime,omitempty"` + // StartTime - The time that the job execution started. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The time that the job execution completed. + EndTime *date.Time `json:"endTime,omitempty"` + // CurrentAttempts - Number of times the job execution has been attempted. + CurrentAttempts *int32 `json:"currentAttempts,omitempty"` + // CurrentAttemptStartTime - Start time of the current attempt. + CurrentAttemptStartTime *date.Time `json:"currentAttemptStartTime,omitempty"` + // LastMessage - The last status or error message. + LastMessage *string `json:"lastMessage,omitempty"` + // Target - The target that this execution is executed on. + Target *JobExecutionTarget `json:"target,omitempty"` +} + +// JobExecutionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type JobExecutionsCreateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future JobExecutionsCreateFuture) Result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return je, azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + je, err = client.CreateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var resp *http.Response + resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", resp, "Failure sending request") + return + } + je, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// JobExecutionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobExecutionsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future JobExecutionsCreateOrUpdateFuture) Result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return je, azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + je, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var resp *http.Response + resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + je, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// JobExecutionTarget the target that a job execution is executed on. +type JobExecutionTarget struct { + // Type - The type of the target. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' + Type JobTargetType `json:"type,omitempty"` + // ServerName - The server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The database name. + DatabaseName *string `json:"databaseName,omitempty"` +} + +// JobListResult a list of jobs. +type JobListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]Job `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobListResultIterator provides access to a complete listing of Job values. +type JobListResultIterator struct { + i int + page JobListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobListResultIterator) Response() JobListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobListResultIterator) Value() Job { + if !iter.page.NotDone() { + return Job{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jlr JobListResult) IsEmpty() bool { + return jlr.Value == nil || len(*jlr.Value) == 0 +} + +// jobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jlr JobListResult) jobListResultPreparer() (*http.Request, error) { + if jlr.NextLink == nil || len(to.String(jlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jlr.NextLink))) +} + +// JobListResultPage contains a page of Job values. +type JobListResultPage struct { + fn func(JobListResult) (JobListResult, error) + jlr JobListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobListResultPage) Next() error { + next, err := page.fn(page.jlr) + if err != nil { + return err + } + page.jlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobListResultPage) NotDone() bool { + return !page.jlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobListResultPage) Response() JobListResult { + return page.jlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobListResultPage) Values() []Job { + if page.jlr.IsEmpty() { + return nil + } + return *page.jlr.Value +} + +// JobProperties properties of a job. +type JobProperties struct { + // Description - User-defined description of the job. + Description *string `json:"description,omitempty"` + // Version - The job version number. + Version *int32 `json:"version,omitempty"` + // Schedule - Schedule properties of the job. + Schedule *JobSchedule `json:"schedule,omitempty"` +} + +// JobSchedule scheduling properties of a job. +type JobSchedule struct { + // StartTime - Schedule start time. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Schedule end time. + EndTime *date.Time `json:"endTime,omitempty"` + // Type - Schedule interval type. Possible values include: 'Once', 'Recurring' + Type JobScheduleType `json:"type,omitempty"` + // Enabled - Whether or not the schedule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Interval - Value of the schedule's recurring interval, if the scheduletype is recurring. ISO8601 duration format. + Interval *string `json:"interval,omitempty"` +} + +// JobStep a job step. +type JobStep struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // JobStepProperties - Resource properties. + *JobStepProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for JobStep struct. +func (js *JobStep) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties JobStepProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + js.JobStepProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + js.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + js.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + js.Type = &typeVar + } + + return nil +} + +// JobStepAction the action to be executed by a job step. +type JobStepAction struct { + // Type - Type of action being executed by the job step. Possible values include: 'TSQL' + Type JobStepActionType `json:"type,omitempty"` + // Source - The source of the action to execute. Possible values include: 'Inline' + Source JobStepActionSource `json:"source,omitempty"` + // Value - The action value, for example the text of the T-SQL script to execute. + Value *string `json:"value,omitempty"` +} + +// JobStepExecutionOptions the execution options of a job step. +type JobStepExecutionOptions struct { + // TimeoutSeconds - Execution timeout for the job step. + TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` + // RetryAttempts - Maximum number of times the job step will be reattempted if the first attempt fails. + RetryAttempts *int32 `json:"retryAttempts,omitempty"` + // InitialRetryIntervalSeconds - Initial delay between retries for job step execution. + InitialRetryIntervalSeconds *int32 `json:"initialRetryIntervalSeconds,omitempty"` + // MaximumRetryIntervalSeconds - The maximum amount of time to wait between retries for job step execution. + MaximumRetryIntervalSeconds *int32 `json:"maximumRetryIntervalSeconds,omitempty"` + // RetryIntervalBackoffMultiplier - The backoff multiplier for the time between retries. + RetryIntervalBackoffMultiplier *float64 `json:"retryIntervalBackoffMultiplier,omitempty"` +} + +// JobStepListResult a list of job steps. +type JobStepListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]JobStep `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobStepListResultIterator provides access to a complete listing of JobStep values. +type JobStepListResultIterator struct { + i int + page JobStepListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobStepListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobStepListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobStepListResultIterator) Response() JobStepListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobStepListResultIterator) Value() JobStep { + if !iter.page.NotDone() { + return JobStep{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobStepListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// jobStepListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobStepListResult) jobStepListResultPreparer() (*http.Request, error) { + if jslr.NextLink == nil || len(to.String(jslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobStepListResultPage contains a page of JobStep values. +type JobStepListResultPage struct { + fn func(JobStepListResult) (JobStepListResult, error) + jslr JobStepListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobStepListResultPage) Next() error { + next, err := page.fn(page.jslr) + if err != nil { + return err + } + page.jslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobStepListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobStepListResultPage) Response() JobStepListResult { + return page.jslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobStepListResultPage) Values() []JobStep { + if page.jslr.IsEmpty() { + return nil + } + return *page.jslr.Value +} + +// JobStepOutput the output configuration of a job step. +type JobStepOutput struct { + // Type - The output destination type. Possible values include: 'SQLDatabase' + Type JobStepOutputType `json:"type,omitempty"` + // SubscriptionID - The output destination subscription id. + SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` + // ResourceGroup - The output destination resource group. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // Server - The output destination server name. + Server *string `json:"server,omitempty"` + // Database - The output destination database. + Database *string `json:"database,omitempty"` + // Schema - The output destination schema. + Schema *string `json:"schema,omitempty"` + // Table - The output destination table. + Table *string `json:"table,omitempty"` + // Credential - The resource ID of the credential to use to connect to the output destination. + Credential *string `json:"credential,omitempty"` +} + +// JobStepProperties properties of a job step. +type JobStepProperties struct { + // StepID - The job step's index within the job. If not specified when creating the job step, it will be created as the last step. If not specified when updating the job step, the step id is not modified. + StepID *int32 `json:"stepId,omitempty"` + // TargetGroup - The resource ID of the target group that the job step will be executed on. + TargetGroup *string `json:"targetGroup,omitempty"` + // Credential - The resource ID of the job credential that will be used to connect to the targets. + Credential *string `json:"credential,omitempty"` + // Action - The action payload of the job step. + Action *JobStepAction `json:"action,omitempty"` + // Output - Output destination properties of the job step. + Output *JobStepOutput `json:"output,omitempty"` + // ExecutionOptions - Execution options for the job step. + ExecutionOptions *JobStepExecutionOptions `json:"executionOptions,omitempty"` +} + +// JobTarget a job target, for example a specific database or a container of databases that is evaluated during job +// execution. +type JobTarget struct { + // MembershipType - Whether the target is included or excluded from the group. Possible values include: 'Include', 'Exclude' + MembershipType JobTargetGroupMembershipType `json:"membershipType,omitempty"` + // Type - The target type. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' + Type JobTargetType `json:"type,omitempty"` + // ServerName - The target server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The target database name. + DatabaseName *string `json:"databaseName,omitempty"` + // ElasticPoolName - The target elastic pool name. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ShardMapName - The target shard map. + ShardMapName *string `json:"shardMapName,omitempty"` + // RefreshCredential - The resource ID of the credential that is used during job execution to connect to the target and determine the list of databases inside the target. + RefreshCredential *string `json:"refreshCredential,omitempty"` +} + +// JobTargetGroup a group of job targets. +type JobTargetGroup struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // JobTargetGroupProperties - Resource properties. + *JobTargetGroupProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for JobTargetGroup struct. +func (jtg *JobTargetGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties JobTargetGroupProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + jtg.JobTargetGroupProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + jtg.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + jtg.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + jtg.Type = &typeVar + } + + return nil +} + +// JobTargetGroupListResult a list of target groups. +type JobTargetGroupListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]JobTargetGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobTargetGroupListResultIterator provides access to a complete listing of JobTargetGroup values. +type JobTargetGroupListResultIterator struct { + i int + page JobTargetGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobTargetGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobTargetGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobTargetGroupListResultIterator) Response() JobTargetGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobTargetGroupListResultIterator) Value() JobTargetGroup { + if !iter.page.NotDone() { + return JobTargetGroup{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (jtglr JobTargetGroupListResult) IsEmpty() bool { + return jtglr.Value == nil || len(*jtglr.Value) == 0 +} + +// jobTargetGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jtglr JobTargetGroupListResult) jobTargetGroupListResultPreparer() (*http.Request, error) { + if jtglr.NextLink == nil || len(to.String(jtglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jtglr.NextLink))) +} + +// JobTargetGroupListResultPage contains a page of JobTargetGroup values. +type JobTargetGroupListResultPage struct { + fn func(JobTargetGroupListResult) (JobTargetGroupListResult, error) + jtglr JobTargetGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobTargetGroupListResultPage) Next() error { + next, err := page.fn(page.jtglr) + if err != nil { + return err + } + page.jtglr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobTargetGroupListResultPage) NotDone() bool { + return !page.jtglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobTargetGroupListResultPage) Response() JobTargetGroupListResult { + return page.jtglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobTargetGroupListResultPage) Values() []JobTargetGroup { + if page.jtglr.IsEmpty() { + return nil + } + return *page.jtglr.Value +} + +// JobTargetGroupProperties properties of job target group. +type JobTargetGroupProperties struct { + // Members - Members of the target group. + Members *[]JobTarget `json:"members,omitempty"` +} + +// JobVersion a job version. +type JobVersion struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// JobVersionListResult a list of job versions. +type JobVersionListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]JobVersion `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// JobVersionListResultIterator provides access to a complete listing of JobVersion values. +type JobVersionListResultIterator struct { + i int + page JobVersionListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobVersionListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() if err != nil { + iter.i-- return err } - var v *json.RawMessage + iter.i = 0 + return nil +} - v = m["name"] - if v != nil { - var name string - err = json.Unmarshal(*m["name"], &name) - if err != nil { - return err - } - ier.Name = &name - } +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobVersionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} - v = m["type"] - if v != nil { - var typeVar string - err = json.Unmarshal(*m["type"], &typeVar) - if err != nil { - return err - } - ier.Type = &typeVar +// Response returns the raw server response from the last page request. +func (iter JobVersionListResultIterator) Response() JobVersionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobVersionListResultIterator) Value() JobVersion { + if !iter.page.NotDone() { + return JobVersion{} } + return iter.page.Values()[iter.i] +} - v = m["properties"] - if v != nil { - var properties ImportExtensionProperties - err = json.Unmarshal(*m["properties"], &properties) - if err != nil { - return err - } - ier.ImportExtensionProperties = &properties +// IsEmpty returns true if the ListResult contains no values. +func (jvlr JobVersionListResult) IsEmpty() bool { + return jvlr.Value == nil || len(*jvlr.Value) == 0 +} + +// jobVersionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jvlr JobVersionListResult) jobVersionListResultPreparer() (*http.Request, error) { + if jvlr.NextLink == nil || len(to.String(jvlr.NextLink)) < 1 { + return nil, nil } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jvlr.NextLink))) +} +// JobVersionListResultPage contains a page of JobVersion values. +type JobVersionListResultPage struct { + fn func(JobVersionListResult) (JobVersionListResult, error) + jvlr JobVersionListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobVersionListResultPage) Next() error { + next, err := page.fn(page.jvlr) + if err != nil { + return err + } + page.jvlr = next return nil } -// ImportRequest import database parameters. -type ImportRequest struct { - // StorageKeyType - The type of the storage key to use. Possible values include: 'StorageAccessKey', 'SharedAccessKey' - StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` - // StorageKey - The storage key to use. If storage key type is SharedAccessKey, it must be preceded with a "?." - StorageKey *string `json:"storageKey,omitempty"` - // StorageURI - The storage uri to use. - StorageURI *string `json:"storageUri,omitempty"` - // AdministratorLogin - The name of the SQL administrator. - AdministratorLogin *string `json:"administratorLogin,omitempty"` - // AdministratorLoginPassword - The password of the SQL administrator. - AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` - // AuthenticationType - The authentication type. Possible values include: 'SQL', 'ADPassword' - AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` - // DatabaseName - The name of the database to import. - DatabaseName *string `json:"databaseName,omitempty"` - // Edition - The edition for the database being created. Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2' - Edition DatabaseEdition `json:"edition,omitempty"` - // ServiceObjectiveName - The name of the service objective to assign to the database. Possible values include: 'ServiceObjectiveNameSystem', 'ServiceObjectiveNameSystem0', 'ServiceObjectiveNameSystem1', 'ServiceObjectiveNameSystem2', 'ServiceObjectiveNameSystem3', 'ServiceObjectiveNameSystem4', 'ServiceObjectiveNameSystem2L', 'ServiceObjectiveNameSystem3L', 'ServiceObjectiveNameSystem4L', 'ServiceObjectiveNameFree', 'ServiceObjectiveNameBasic', 'ServiceObjectiveNameS0', 'ServiceObjectiveNameS1', 'ServiceObjectiveNameS2', 'ServiceObjectiveNameS3', 'ServiceObjectiveNameS4', 'ServiceObjectiveNameS6', 'ServiceObjectiveNameS7', 'ServiceObjectiveNameS9', 'ServiceObjectiveNameS12', 'ServiceObjectiveNameP1', 'ServiceObjectiveNameP2', 'ServiceObjectiveNameP3', 'ServiceObjectiveNameP4', 'ServiceObjectiveNameP6', 'ServiceObjectiveNameP11', 'ServiceObjectiveNameP15', 'ServiceObjectiveNamePRS1', 'ServiceObjectiveNamePRS2', 'ServiceObjectiveNamePRS4', 'ServiceObjectiveNamePRS6', 'ServiceObjectiveNameDW100', 'ServiceObjectiveNameDW200', 'ServiceObjectiveNameDW300', 'ServiceObjectiveNameDW400', 'ServiceObjectiveNameDW500', 'ServiceObjectiveNameDW600', 'ServiceObjectiveNameDW1000', 'ServiceObjectiveNameDW1200', 'ServiceObjectiveNameDW1000c', 'ServiceObjectiveNameDW1500', 'ServiceObjectiveNameDW1500c', 'ServiceObjectiveNameDW2000', 'ServiceObjectiveNameDW2000c', 'ServiceObjectiveNameDW3000', 'ServiceObjectiveNameDW2500c', 'ServiceObjectiveNameDW3000c', 'ServiceObjectiveNameDW6000', 'ServiceObjectiveNameDW5000c', 'ServiceObjectiveNameDW6000c', 'ServiceObjectiveNameDW7500c', 'ServiceObjectiveNameDW10000c', 'ServiceObjectiveNameDW15000c', 'ServiceObjectiveNameDW30000c', 'ServiceObjectiveNameDS100', 'ServiceObjectiveNameDS200', 'ServiceObjectiveNameDS300', 'ServiceObjectiveNameDS400', 'ServiceObjectiveNameDS500', 'ServiceObjectiveNameDS600', 'ServiceObjectiveNameDS1000', 'ServiceObjectiveNameDS1200', 'ServiceObjectiveNameDS1500', 'ServiceObjectiveNameDS2000', 'ServiceObjectiveNameElasticPool' - ServiceObjectiveName ServiceObjectiveName `json:"serviceObjectiveName,omitempty"` - // MaxSizeBytes - The maximum size for the newly imported database. - MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobVersionListResultPage) NotDone() bool { + return !page.jvlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobVersionListResultPage) Response() JobVersionListResult { + return page.jvlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobVersionListResultPage) Values() []JobVersion { + if page.jvlr.IsEmpty() { + return nil + } + return *page.jvlr.Value } // LocationCapabilities the capabilities for a location. @@ -4275,7 +6206,7 @@ func (ri *RecommendedIndex) UnmarshalJSON(body []byte) error { type RecommendedIndexProperties struct { // Action - The proposed index action. You can create a missing index, drop an unused index, or rebuild an existing index to improve its performance. Possible values include: 'Create', 'Drop', 'Rebuild' Action RecommendedIndexAction `json:"action,omitempty"` - // State - The current recommendation state. Possible values include: 'RecommendedIndexStateActive', 'RecommendedIndexStatePending', 'RecommendedIndexStateExecuting', 'RecommendedIndexStateVerifying', 'RecommendedIndexStatePendingRevert', 'RecommendedIndexStateReverting', 'RecommendedIndexStateReverted', 'RecommendedIndexStateIgnored', 'RecommendedIndexStateExpired', 'RecommendedIndexStateBlocked', 'RecommendedIndexStateSuccess' + // State - The current recommendation state. Possible values include: 'Active', 'Pending', 'Executing', 'Verifying', 'PendingRevert', 'Reverting', 'Reverted', 'Ignored', 'Expired', 'Blocked', 'Success' State RecommendedIndexState `json:"state,omitempty"` // Created - The UTC datetime showing when this resource was created (ISO8601 format). Created *date.Time `json:"created,omitempty"` @@ -4504,22 +6435,30 @@ func (future ReplicationLinksFailoverAllowDataLossFuture) Result(client Replicat var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.FailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") return } ar, err = client.FailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } return } @@ -4535,22 +6474,30 @@ func (future ReplicationLinksFailoverFuture) Result(client ReplicationLinksClien var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ReplicationLinksFailoverFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure sending request") return } ar, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure responding to request") + } return } @@ -4897,6 +6844,71 @@ type ServerAdministratorProperties struct { TenantID *uuid.UUID `json:"tenantId,omitempty"` } +// ServerAutomaticTuning server-level Automatic Tuning. +type ServerAutomaticTuning struct { + autorest.Response `json:"-"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // AutomaticTuningServerProperties - Resource properties. + *AutomaticTuningServerProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ServerAutomaticTuning struct. +func (sat *ServerAutomaticTuning) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + var v *json.RawMessage + + v = m["properties"] + if v != nil { + var properties AutomaticTuningServerProperties + err = json.Unmarshal(*m["properties"], &properties) + if err != nil { + return err + } + sat.AutomaticTuningServerProperties = &properties + } + + v = m["id"] + if v != nil { + var ID string + err = json.Unmarshal(*m["id"], &ID) + if err != nil { + return err + } + sat.ID = &ID + } + + v = m["name"] + if v != nil { + var name string + err = json.Unmarshal(*m["name"], &name) + if err != nil { + return err + } + sat.Name = &name + } + + v = m["type"] + if v != nil { + var typeVar string + err = json.Unmarshal(*m["type"], &typeVar) + if err != nil { + return err + } + sat.Type = &typeVar + } + + return nil +} + // ServerAzureADAdministrator an server Active Directory Administrator. type ServerAzureADAdministrator struct { autorest.Response `json:"-"` @@ -4975,22 +6987,30 @@ func (future ServerAzureADAdministratorsCreateOrUpdateFuture) Result(client Serv var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return saaa, autorest.NewError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { saaa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } saaa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5007,22 +7027,30 @@ func (future ServerAzureADAdministratorsDeleteFuture) Result(client ServerAzureA var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return saaa, autorest.NewError("sql.ServerAzureADAdministratorsDeleteFuture", "Result", "asynchronous operation has not completed") + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { saaa, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure sending request") return } saaa, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -5143,22 +7171,30 @@ func (future ServerCommunicationLinksCreateOrUpdateFuture) Result(client ServerC var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return scl, autorest.NewError("sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return scl, azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { scl, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } scl, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5340,22 +7376,30 @@ func (future ServerDNSAliasesAcquireFuture) Result(client ServerDNSAliasesClient var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ServerDNSAliasesAcquireFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesAcquireFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.AcquireResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", resp, "Failure sending request") return } ar, err = client.AcquireResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", resp, "Failure responding to request") + } return } @@ -5372,22 +7416,30 @@ func (future ServerDNSAliasesCreateOrUpdateFuture) Result(client ServerDNSAliase var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sda, autorest.NewError("sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sda, azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sda, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sda, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5403,22 +7455,30 @@ func (future ServerDNSAliasesDeleteFuture) Result(client ServerDNSAliasesClient) var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ServerDNSAliasesDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -5747,22 +7807,30 @@ func (future ServerKeysCreateOrUpdateFuture) Result(client ServerKeysClient) (sk var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sk, autorest.NewError("sql.ServerKeysCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sk, azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sk, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sk, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5778,22 +7846,30 @@ func (future ServerKeysDeleteFuture) Result(client ServerKeysClient) (ar autores var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ServerKeysDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -5925,22 +8001,30 @@ func (future ServersCreateOrUpdateFuture) Result(client ServersClient) (s Server var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return s, autorest.NewError("sql.ServersCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return s, azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { s, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } s, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -5956,22 +8040,30 @@ func (future ServersDeleteFuture) Result(client ServersClient) (ar autorest.Resp var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.ServersDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -5987,22 +8079,30 @@ func (future ServersUpdateFuture) Result(client ServersClient) (s Server, err er var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return s, autorest.NewError("sql.ServersUpdateFuture", "Result", "asynchronous operation has not completed") + return s, azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { s, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure sending request") return } s, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -6946,22 +9046,30 @@ func (future SyncAgentsCreateOrUpdateFuture) Result(client SyncAgentsClient) (sa var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sa, autorest.NewError("sql.SyncAgentsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sa, azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -6977,22 +9085,30 @@ func (future SyncAgentsDeleteFuture) Result(client SyncAgentsClient) (ar autores var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncAgentsDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -7519,7 +9635,7 @@ func (page SyncGroupLogListResultPage) Values() []SyncGroupLogProperties { type SyncGroupLogProperties struct { // Timestamp - Timestamp of the sync group log. Timestamp *date.Time `json:"timestamp,omitempty"` - // Type - Type of the sync group log. Possible values include: 'All', 'Error', 'Warning', 'Success' + // Type - Type of the sync group log. Possible values include: 'SyncGroupLogTypeAll', 'SyncGroupLogTypeError', 'SyncGroupLogTypeWarning', 'SyncGroupLogTypeSuccess' Type SyncGroupLogType `json:"type,omitempty"` // Source - Source of the sync group log. Source *string `json:"source,omitempty"` @@ -7545,7 +9661,7 @@ type SyncGroupProperties struct { HubDatabaseUserName *string `json:"hubDatabaseUserName,omitempty"` // HubDatabasePassword - Password for the sync group hub database credential. HubDatabasePassword *string `json:"hubDatabasePassword,omitempty"` - // SyncState - Sync state of the sync group. Possible values include: 'SyncGroupStateNotReady', 'SyncGroupStateError', 'SyncGroupStateWarning', 'SyncGroupStateProgressing', 'SyncGroupStateGood' + // SyncState - Sync state of the sync group. Possible values include: 'NotReady', 'Error', 'Warning', 'Progressing', 'Good' SyncState SyncGroupState `json:"syncState,omitempty"` // Schema - Sync schema of the sync group. Schema *SyncGroupSchema `json:"schema,omitempty"` @@ -7589,22 +9705,30 @@ func (future SyncGroupsCreateOrUpdateFuture) Result(client SyncGroupsClient) (sg var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sg, autorest.NewError("sql.SyncGroupsCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7620,22 +9744,30 @@ func (future SyncGroupsDeleteFuture) Result(client SyncGroupsClient) (ar autores var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncGroupsDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -7652,22 +9784,30 @@ func (future SyncGroupsRefreshHubSchemaFuture) Result(client SyncGroupsClient) ( var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncGroupsRefreshHubSchemaFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.RefreshHubSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure sending request") return } ar, err = client.RefreshHubSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure responding to request") + } return } @@ -7683,22 +9823,30 @@ func (future SyncGroupsUpdateFuture) Result(client SyncGroupsClient) (sg SyncGro var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sg, autorest.NewError("sql.SyncGroupsUpdateFuture", "Result", "asynchronous operation has not completed") + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure sending request") return } sg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7904,22 +10052,30 @@ func (future SyncMembersCreateOrUpdateFuture) Result(client SyncMembersClient) ( var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sm, autorest.NewError("sql.SyncMembersCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sm, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } sm, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -7935,22 +10091,30 @@ func (future SyncMembersDeleteFuture) Result(client SyncMembersClient) (ar autor var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncMembersDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure responding to request") + } return } @@ -7967,22 +10131,30 @@ func (future SyncMembersRefreshMemberSchemaFuture) Result(client SyncMembersClie var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.SyncMembersRefreshMemberSchemaFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.RefreshMemberSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure sending request") return } ar, err = client.RefreshMemberSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure responding to request") + } return } @@ -7998,22 +10170,30 @@ func (future SyncMembersUpdateFuture) Result(client SyncMembersClient) (sm SyncM var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return sm, autorest.NewError("sql.SyncMembersUpdateFuture", "Result", "asynchronous operation has not completed") + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { sm, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure sending request") return } sm, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -8397,22 +10577,30 @@ func (future VirtualNetworkRulesCreateOrUpdateFuture) Result(client VirtualNetwo var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - return vnr, autorest.NewError("sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", "asynchronous operation has not completed") + return vnr, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") } if future.PollingMethod() == azure.PollingLocation { vnr, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure sending request") return } vnr, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } return } @@ -8429,21 +10617,29 @@ func (future VirtualNetworkRulesDeleteFuture) Result(client VirtualNetworkRulesC var done bool done, err = future.Done(client) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - return ar, autorest.NewError("sql.VirtualNetworkRulesDeleteFuture", "Result", "asynchronous operation has not completed") + return ar, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") } if future.PollingMethod() == azure.PollingLocation { ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } return } var resp *http.Response resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure sending request") return } ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure responding to request") + } return } diff --git a/services/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go b/services/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go new file mode 100644 index 000000000000..30b3338f17e9 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go @@ -0,0 +1,179 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServerAutomaticTuningClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ServerAutomaticTuningClient struct { + BaseClient +} + +// NewServerAutomaticTuningClient creates an instance of the ServerAutomaticTuningClient client. +func NewServerAutomaticTuningClient(subscriptionID string) ServerAutomaticTuningClient { + return NewServerAutomaticTuningClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAutomaticTuningClientWithBaseURI creates an instance of the ServerAutomaticTuningClient client. +func NewServerAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) ServerAutomaticTuningClient { + return ServerAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieves server automatic tuning options. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAutomaticTuning, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAutomaticTuningClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAutomaticTuningClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAutomaticTuningClient) GetResponder(resp *http.Response) (result ServerAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning options on server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from the +// Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// automatic tuning resource state. +func (client ServerAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (result ServerAutomaticTuning, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServerAutomaticTuningClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAutomaticTuningClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServerAutomaticTuningClient) UpdateResponder(resp *http.Response) (result ServerAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/version.go b/services/sql/mgmt/2017-03-01-preview/sql/version.go index 97e0377bebd0..2dd0fd91b7e6 100644 --- a/services/sql/mgmt/2017-03-01-preview/sql/version.go +++ b/services/sql/mgmt/2017-03-01-preview/sql/version.go @@ -19,10 +19,10 @@ package sql // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v12.1.1-beta services" + return "Azure-SDK-For-Go/v12.2.1-beta services" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v12.1.1-beta" + return "v12.2.1-beta" }