From 35be95e6e55f9a2ade50ac3c8b262eae9b895ef1 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 25 May 2022 14:36:28 +0000 Subject: [PATCH] CodeGen from PR 19224 in Azure/azure-rest-api-specs Merge 74d92a9ebd28ce6c6e0f4c71a1d7c716badf37bc into f07a80688b1b43cf9ffc1db1a8858a42fd3184b3 --- .../mgmt/2015-05-01-preview/sql/CHANGELOG.md | 2 + .../mgmt/2015-05-01-preview/sql/_meta.json | 11 + .../2015-05-01-preview/sql/capabilities.go | 107 + .../sql/mgmt/2015-05-01-preview/sql/client.go | 42 + .../sql/databaseblobauditingpolicies.go | 319 + .../mgmt/2015-05-01-preview/sql/databases.go | 1373 + .../sql/databasethreatdetectionpolicies.go | 198 + .../2015-05-01-preview/sql/databaseusages.go | 112 + .../sql/datamaskingpolicies.go | 199 + .../sql/datamaskingrules.go | 212 + .../sql/elasticpoolactivities.go | 113 + .../sql/elasticpooldatabaseactivities.go | 113 + .../2015-05-01-preview/sql/elasticpools.go | 598 + .../sql/encryptionprotectors.go | 397 + .../sql/mgmt/2015-05-01-preview/sql/enums.go | 1060 + .../2015-05-01-preview/sql/failovergroups.go | 658 + .../2015-05-01-preview/sql/firewallrules.go | 361 + .../sql/geobackuppolicies.go | 285 + .../sql/managedinstances.go | 594 + .../sql/mgmt/2015-05-01-preview/sql/models.go | 10306 ++++++ .../mgmt/2015-05-01-preview/sql/operations.go | 142 + .../sql/recoverabledatabases.go | 190 + .../sql/replicationlinks.go | 527 + .../sql/restorabledroppeddatabases.go | 191 + .../2015-05-01-preview/sql/restorepoints.go | 112 + .../sql/serverazureadadministrators.go | 367 + .../sql/servercommunicationlinks.go | 363 + .../sql/serverconnectionpolicies.go | 195 + .../mgmt/2015-05-01-preview/sql/serverkeys.go | 401 + .../mgmt/2015-05-01-preview/sql/servers.go | 669 + .../2015-05-01-preview/sql/serverusages.go | 110 + .../sql/serviceobjectives.go | 190 + .../sql/servicetieradvisors.go | 194 + .../sql/sqlapi/interfaces.go | 386 + .../sql/subscriptionusages.go | 226 + .../mgmt/2015-05-01-preview/sql/syncagents.go | 597 + .../mgmt/2015-05-01-preview/sql/syncgroups.go | 1107 + .../2015-05-01-preview/sql/syncmembers.go | 712 + .../transparentdataencryptionactivities.go | 0 .../sql/transparentdataencryptions.go | 198 + .../mgmt/2015-05-01-preview/sql/version.go | 19 + .../2015-05-01-preview/sql/virtualclusters.go | 502 + .../sql/virtualnetworkrules.go | 406 + .../mgmt/2017-03-01-preview/sql/CHANGELOG.md | 41 +- .../mgmt/2017-03-01-preview/sql/_meta.json | 2 +- .../sql/mgmt/2017-03-01-preview/sql/enums.go | 60 +- .../sql/mgmt/2017-03-01-preview/sql/models.go | 18 +- .../mgmt/2017-10-01-preview/sql/CHANGELOG.md | 2 + .../mgmt/2017-10-01-preview/sql/_meta.json | 11 + .../sql/backupshorttermretentionpolicies.go | 407 + .../2017-10-01-preview/sql/capabilities.go | 111 + .../sql/mgmt/2017-10-01-preview/sql/client.go | 42 + .../sql/databaseoperations.go | 236 + .../mgmt/2017-10-01-preview/sql/databases.go | 949 + .../databasevulnerabilityassessmentscans.go | 405 + .../sql/elasticpooloperations.go | 234 + .../2017-10-01-preview/sql/elasticpools.go | 495 + .../sql/mgmt/2017-10-01-preview/sql/enums.go | 409 + .../sql/instancefailovergroups.go | 574 + ...asevulnerabilityassessmentrulebaselines.go | 300 + ...manageddatabasevulnerabilityassessments.go | 398 + ...geddatabasevulnerabilityassessmentscans.go | 405 + .../managedinstanceencryptionprotectors.go | 397 + .../sql/managedinstancekeys.go | 403 + .../sql/managedinstancetdecertificates.go | 124 + .../sql/mgmt/2017-10-01-preview/sql/models.go | 5051 +++ .../sql/recoverablemanageddatabases.go | 231 + .../sql/sqlapi/interfaces.go | 180 + .../2017-10-01-preview/sql/tdecertificates.go | 123 + .../mgmt/2017-10-01-preview/sql/version.go | 19 + .../mgmt/2018-06-01-preview/sql/CHANGELOG.md | 28 +- .../mgmt/2018-06-01-preview/sql/_meta.json | 2 +- .../sql/mgmt/2018-06-01-preview/sql/enums.go | 30 +- .../sql/mgmt/2018-06-01-preview/sql/models.go | 4 +- .../preview/sql/mgmt/v3.0/sql/CHANGELOG.md | 2 + services/preview/sql/mgmt/v3.0/sql/_meta.json | 11 + .../sql/backuplongtermretentionpolicies.go | 0 .../sql/backupshorttermretentionpolicies.go | 407 + .../preview/sql/mgmt/v3.0/sql/capabilities.go | 111 + services/preview/sql/mgmt/v3.0/sql/client.go | 42 + .../mgmt/v3.0/sql/databaseautomatictuning.go | 195 + .../v3.0/sql/databaseblobauditingpolicies.go | 319 + .../sql/mgmt/v3.0/sql/databaseoperations.go | 236 + .../preview/sql/mgmt/v3.0/sql/databases.go | 1407 + .../sql/databasethreatdetectionpolicies.go | 198 + .../sql/mgmt/v3.0/sql/databaseusages.go | 112 + ...asevulnerabilityassessmentrulebaselines.go | 300 + .../sql/databasevulnerabilityassessments.go | 397 + .../databasevulnerabilityassessmentscans.go | 405 + .../sql/mgmt/v3.0/sql/datamaskingpolicies.go | 199 + .../sql/mgmt/v3.0/sql/datamaskingrules.go | 212 + .../mgmt/v3.0/sql/elasticpoolactivities.go | 113 + .../v3.0/sql/elasticpooldatabaseactivities.go | 113 + .../mgmt/v3.0/sql/elasticpooloperations.go | 234 + .../preview/sql/mgmt/v3.0/sql/elasticpools.go | 736 + .../sql/mgmt/v3.0/sql/encryptionprotectors.go | 397 + services/preview/sql/mgmt/v3.0/sql/enums.go | 1987 ++ .../extendeddatabaseblobauditingpolicies.go | 319 + .../sql/extendedserverblobauditingpolicies.go | 316 + .../sql/mgmt/v3.0/sql/failovergroups.go | 658 + .../sql/mgmt/v3.0/sql/firewallrules.go | 361 + .../sql/mgmt/v3.0/sql/geobackuppolicies.go | 285 + .../preview/sql/mgmt/v3.0/sql/importexport.go | 128 + .../mgmt/v3.0/sql/instancefailovergroups.go | 574 + .../sql/mgmt/v3.0/sql/instancepools.go | 597 + .../preview/sql/mgmt/v3.0/sql/jobagents.go | 492 + .../sql/mgmt/v3.0/sql/jobcredentials.go | 409 + .../sql/mgmt/v3.0/sql/jobexecutions.go | 670 + services/preview/sql/mgmt/v3.0/sql/jobs.go | 399 + .../sql/mgmt/v3.0/sql/jobstepexecutions.go | 274 + .../preview/sql/mgmt/v3.0/sql/jobsteps.go | 635 + .../sql/mgmt/v3.0/sql/jobtargetexecutions.go | 431 + .../sql/mgmt/v3.0/sql/jobtargetgroups.go | 407 + .../preview/sql/mgmt/v3.0/sql/jobversions.go | 239 + .../mgmt/v3.0/sql/longtermretentionbackups.go | 1129 + ...longtermretentionmanagedinstancebackups.go | 1130 + ...managedbackupshorttermretentionpolicies.go | 408 + .../sql/mgmt/v3.0/sql/manageddatabases.go | 693 + .../manageddatabasesecurityalertpolicies.go | 319 + .../sql/manageddatabasesensitivitylabels.go | 723 + ...asevulnerabilityassessmentrulebaselines.go | 300 + ...manageddatabasevulnerabilityassessments.go | 398 + ...geddatabasevulnerabilityassessmentscans.go | 405 + .../v3.0/sql/managedinstanceadministrators.go | 406 + ...nagedinstanceazureadonlyauthentications.go | 406 + .../managedinstanceencryptionprotectors.go | 397 + .../sql/mgmt/v3.0/sql/managedinstancekeys.go | 403 + ...anagedinstancelongtermretentionpolicies.go | 322 + .../v3.0/sql/managedinstanceoperations.go | 309 + .../sql/mgmt/v3.0/sql/managedinstances.go | 944 + .../sql/managedinstancetdecertificates.go | 124 + ...managedinstancevulnerabilityassessments.go | 398 + ...atabasebackupshorttermretentionpolicies.go | 404 + .../sql/managedserversecurityalertpolicies.go | 316 + services/preview/sql/mgmt/v3.0/sql/models.go | 26683 ++++++++++++++++ .../preview/sql/mgmt/v3.0/sql/operations.go | 142 + .../v3.0/sql/privateendpointconnections.go | 405 + .../sql/mgmt/v3.0/sql/privatelinkresources.go | 232 + .../mgmt/v3.0/sql/recommendedelasticpools.go | 269 + .../sql/mgmt/v3.0/sql/recoverabledatabases.go | 190 + .../v3.0/sql/recoverablemanageddatabases.go | 231 + .../sql/mgmt/v3.0/sql/replicationlinks.go | 527 + .../v3.0/sql/restorabledroppeddatabases.go | 191 + .../sql/restorabledroppedmanageddatabases.go | 232 + .../sql/mgmt/v3.0/sql/restorepoints.go | 365 + .../sql/mgmt/v3.0/sql/sensitivitylabels.go | 723 + .../mgmt/v3.0/sql/serverautomatictuning.go | 191 + .../v3.0/sql/serverazureadadministrators.go | 406 + .../sql/serverazureadonlyauthentications.go | 405 + .../v3.0/sql/serverblobauditingpolicies.go | 315 + .../mgmt/v3.0/sql/servercommunicationlinks.go | 363 + .../mgmt/v3.0/sql/serverconnectionpolicies.go | 195 + .../sql/mgmt/v3.0/sql/serverdnsaliases.go | 478 + .../preview/sql/mgmt/v3.0/sql/serverkeys.go | 401 + services/preview/sql/mgmt/v3.0/sql/servers.go | 761 + .../v3.0/sql/serversecurityalertpolicies.go | 315 + .../sql/mgmt/v3.0/sql/servertrustgroups.go | 527 + .../preview/sql/mgmt/v3.0/sql/serverusages.go | 110 + .../sql/servervulnerabilityassessments.go | 397 + .../sql/mgmt/v3.0/sql/serviceobjectives.go | 190 + .../sql/mgmt/v3.0/sql/servicetieradvisors.go | 194 + .../sql/mgmt/v3.0/sql/sqlapi/interfaces.go | 1038 + .../sql/mgmt/v3.0/sql/subscriptionusages.go | 226 + .../preview/sql/mgmt/v3.0/sql/syncagents.go | 597 + .../preview/sql/mgmt/v3.0/sql/syncgroups.go | 1107 + .../preview/sql/mgmt/v3.0/sql/syncmembers.go | 712 + .../sql/mgmt/v3.0/sql/tdecertificates.go | 123 + .../transparentdataencryptionactivities.go | 115 + .../v3.0/sql/transparentdataencryptions.go | 198 + services/preview/sql/mgmt/v3.0/sql/usages.go | 156 + services/preview/sql/mgmt/v3.0/sql/version.go | 19 + .../sql/mgmt/v3.0/sql/virtualclusters.go | 502 + .../sql/mgmt/v3.0/sql/virtualnetworkrules.go | 406 + .../sql/mgmt/v3.0/sql/workloadclassifiers.go | 422 + .../sql/mgmt/v3.0/sql/workloadgroups.go | 416 + .../preview/sql/mgmt/v4.0/sql/CHANGELOG.md | 336 +- services/preview/sql/mgmt/v4.0/sql/_meta.json | 2 +- .../preview/sql/mgmt/v4.0/sql/databases.go | 24 +- services/preview/sql/mgmt/v4.0/sql/enums.go | 200 +- .../mgmt/v4.0/sql/longtermretentionbackups.go | 406 +- ...longtermretentionmanagedinstancebackups.go | 36 +- .../v4.0/sql/longtermretentionpolicies.go | 321 + services/preview/sql/mgmt/v4.0/sql/models.go | 1263 +- .../v4.0/sql/privateendpointconnections.go | 8 +- .../sql/mgmt/v4.0/sql/sqlapi/interfaces.go | 113 +- .../preview/sql/mgmt/v5.0/sql/CHANGELOG.md | 623 +- services/preview/sql/mgmt/v5.0/sql/_meta.json | 2 +- ...atabaseadvancedthreatprotectionsettings.go | 320 + .../v5.0/sql/databaseblobauditingpolicies.go | 6 +- .../preview/sql/mgmt/v5.0/sql/databases.go | 28 +- .../v5.0/sql/databasesecurityalertpolicies.go | 4 +- .../v5.0/sql/distributedavailabilitygroups.go | 483 + .../preview/sql/mgmt/v5.0/sql/elasticpools.go | 18 +- .../sql/mgmt/v5.0/sql/endpointcertificates.go | 232 + services/preview/sql/mgmt/v5.0/sql/enums.go | 221 +- .../extendeddatabaseblobauditingpolicies.go | 6 +- .../sql/extendedserverblobauditingpolicies.go | 6 +- .../sql/mgmt/v5.0/sql/ipv6firewallrules.go | 392 + .../sql/mgmt/v5.0/sql/ledgerdigestuploads.go | 62 +- .../mgmt/v5.0/sql/longtermretentionbackups.go | 28 +- ...longtermretentionmanagedinstancebackups.go | 20 +- .../manageddatabasesecurityalertpolicies.go | 4 +- .../sql/mgmt/v5.0/sql/managedinstances.go | 18 +- .../mgmt/v5.0/sql/managedserverdnsaliases.go | 484 + services/preview/sql/mgmt/v5.0/sql/models.go | 18508 ++++++----- .../sql/mgmt/v5.0/sql/operationshealth.go | 150 - .../sql/mgmt/v5.0/sql/replicationlinks.go | 132 +- .../v5.0/sql/restorabledroppeddatabases.go | 4 +- .../sql/restorabledroppedmanageddatabases.go | 4 +- .../serveradvancedthreatprotectionsettings.go | 317 + .../v5.0/sql/serverblobauditingpolicies.go | 6 +- .../mgmt/v5.0/sql/serverconnectionpolicies.go | 164 +- .../mgmt/v5.0/sql/servertrustcertificates.go | 399 + .../sql/mgmt/v5.0/sql/sqlapi/interfaces.go | 509 +- .../preview/sql/mgmt/v5.0/sql/syncgroups.go | 6 +- .../v5.0/sql/transparentdataencryptions.go | 172 +- services/sql/mgmt/2014-04-01/sql/CHANGELOG.md | 2 +- services/sql/mgmt/2014-04-01/sql/_meta.json | 2 +- 218 files changed, 119955 insertions(+), 9377 deletions(-) create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/CHANGELOG.md create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/_meta.json create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/capabilities.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/client.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/databaseblobauditingpolicies.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/databases.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/databasethreatdetectionpolicies.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/databaseusages.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingpolicies.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingrules.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpoolactivities.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpooldatabaseactivities.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpools.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/encryptionprotectors.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/enums.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/failovergroups.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/firewallrules.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/geobackuppolicies.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/managedinstances.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/models.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/operations.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/recoverabledatabases.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/replicationlinks.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/restorabledroppeddatabases.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/restorepoints.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/serverazureadadministrators.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/servercommunicationlinks.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/serverconnectionpolicies.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/serverkeys.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/servers.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/serverusages.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/serviceobjectives.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/servicetieradvisors.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/sqlapi/interfaces.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/subscriptionusages.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/syncagents.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/syncgroups.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/syncmembers.go rename services/preview/sql/mgmt/{v5.0 => 2015-05-01-preview}/sql/transparentdataencryptionactivities.go (100%) create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptions.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/version.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/virtualclusters.go create mode 100644 services/preview/sql/mgmt/2015-05-01-preview/sql/virtualnetworkrules.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/CHANGELOG.md create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/_meta.json create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/backupshorttermretentionpolicies.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/capabilities.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/client.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/databaseoperations.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/databases.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/databasevulnerabilityassessmentscans.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpooloperations.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpools.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/enums.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentrulebaselines.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessments.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentscans.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstanceencryptionprotectors.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancekeys.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancetdecertificates.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/models.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/recoverablemanageddatabases.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/sqlapi/interfaces.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/tdecertificates.go create mode 100644 services/preview/sql/mgmt/2017-10-01-preview/sql/version.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/CHANGELOG.md create mode 100644 services/preview/sql/mgmt/v3.0/sql/_meta.json rename services/preview/sql/mgmt/{v4.0 => v3.0}/sql/backuplongtermretentionpolicies.go (100%) create mode 100644 services/preview/sql/mgmt/v3.0/sql/backupshorttermretentionpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/capabilities.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/client.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databaseautomatictuning.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databaseblobauditingpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databaseoperations.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databasethreatdetectionpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databaseusages.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentrulebaselines.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessments.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentscans.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/datamaskingpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/datamaskingrules.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/elasticpoolactivities.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/elasticpooldatabaseactivities.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/elasticpooloperations.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/elasticpools.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/encryptionprotectors.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/enums.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/extendeddatabaseblobauditingpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/extendedserverblobauditingpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/failovergroups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/firewallrules.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/geobackuppolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/importexport.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/instancefailovergroups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/instancepools.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobagents.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobcredentials.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobexecutions.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobs.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobstepexecutions.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobsteps.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobtargetexecutions.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobtargetgroups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/jobversions.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/longtermretentionbackups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/longtermretentionmanagedinstancebackups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedbackupshorttermretentionpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/manageddatabases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/manageddatabasesecurityalertpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/manageddatabasesensitivitylabels.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessments.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentscans.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstanceadministrators.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstanceazureadonlyauthentications.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstanceencryptionprotectors.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstancekeys.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstancelongtermretentionpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstanceoperations.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstances.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstancetdecertificates.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedinstancevulnerabilityassessments.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/managedserversecurityalertpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/models.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/operations.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/privateendpointconnections.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/privatelinkresources.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/recommendedelasticpools.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/recoverabledatabases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/recoverablemanageddatabases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/replicationlinks.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/restorabledroppeddatabases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/restorabledroppedmanageddatabases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/restorepoints.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/sensitivitylabels.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverautomatictuning.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverazureadadministrators.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverazureadonlyauthentications.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverblobauditingpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/servercommunicationlinks.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverconnectionpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverdnsaliases.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverkeys.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/servers.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serversecurityalertpolicies.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/servertrustgroups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serverusages.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/servervulnerabilityassessments.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/serviceobjectives.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/servicetieradvisors.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/sqlapi/interfaces.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/subscriptionusages.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/syncagents.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/syncgroups.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/syncmembers.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/tdecertificates.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/transparentdataencryptionactivities.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/transparentdataencryptions.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/usages.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/version.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/virtualclusters.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/virtualnetworkrules.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/workloadclassifiers.go create mode 100644 services/preview/sql/mgmt/v3.0/sql/workloadgroups.go create mode 100644 services/preview/sql/mgmt/v4.0/sql/longtermretentionpolicies.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/databaseadvancedthreatprotectionsettings.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/distributedavailabilitygroups.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/endpointcertificates.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/ipv6firewallrules.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/managedserverdnsaliases.go delete mode 100644 services/preview/sql/mgmt/v5.0/sql/operationshealth.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/serveradvancedthreatprotectionsettings.go create mode 100644 services/preview/sql/mgmt/v5.0/sql/servertrustcertificates.go diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/CHANGELOG.md b/services/preview/sql/mgmt/2015-05-01-preview/sql/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/_meta.json b/services/preview/sql/mgmt/2015-05-01-preview/sql/_meta.json new file mode 100644 index 000000000000..8dd886198a23 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", + "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "tag": "package-2015-05-preview", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2015-05-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/capabilities.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/capabilities.go new file mode 100644 index 000000000000..6cd6f913706a --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/capabilities.go @@ -0,0 +1,107 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// CapabilitiesClient 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 CapabilitiesClient struct { + BaseClient +} + +// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. +func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { + return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCapabilitiesClientWithBaseURI creates an instance of the CapabilitiesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the subscription capabilities available for the specified location. +// Parameters: +// locationName - the location name whose capabilities are retrieved. +func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationName string) (result LocationCapabilities, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/client.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/client.go new file mode 100644 index 000000000000..99340489081a --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/client.go @@ -0,0 +1,42 @@ +// Package sql implements the Azure ARM Sql service API version . +// +// 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. +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Sql + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Sql. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseblobauditingpolicies.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseblobauditingpolicies.go new file mode 100644 index 000000000000..5f1358cac081 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseblobauditingpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseBlobAuditingPoliciesClient 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 DatabaseBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewDatabaseBlobAuditingPoliciesClient creates an instance of the DatabaseBlobAuditingPoliciesClient client. +func NewDatabaseBlobAuditingPoliciesClient(subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return NewDatabaseBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseBlobAuditingPoliciesClientWithBaseURI creates an instance of the DatabaseBlobAuditingPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return DatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the database blob auditing policy. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (result DatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "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.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "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, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}", 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 DatabaseBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "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.DatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "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}/auditingSettings/{blobAuditingPolicyName}", 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 DatabaseBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists auditing settings of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.dbaplr.Response.Response != nil { + sc = result.dbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dbaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dbaplr.hasNextLink() && result.dbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer(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}/auditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseBlobAuditingPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseBlobAuditingPolicyListResult) (result DatabaseBlobAuditingPolicyListResult, err error) { + req, err := lastResults.databaseBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/databases.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/databases.go new file mode 100644 index 000000000000..5880e5d23b9d --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databases.go @@ -0,0 +1,1373 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabasesClient 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 DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateImportOperation creates an import operation that imports a bacpac into an existing database. The existing +// database must be empty. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to import into +// parameters - the required parameters for importing a Bacpac into a database. +func (client DatabasesClient) CreateImportOperation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ImportExtensionRequest) (result DatabasesCreateImportOperationFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.CreateImportOperation") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ImportExtensionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ImportExtensionProperties.OperationMode", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "CreateImportOperation", err.Error()) + } + + req, err := client.CreateImportOperationPreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", nil, "Failure preparing request") + return + } + + result, err = client.CreateImportOperationSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateImportOperation", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateImportOperationPreparer prepares the CreateImportOperation request. +func (client DatabasesClient) CreateImportOperationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ImportExtensionRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "extensionName": autorest.Encode("path", "import"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateImportOperationSender sends the CreateImportOperation request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateImportOperationSender(req *http.Request) (future DatabasesCreateImportOperationFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateImportOperationResponder handles the response to the CreateImportOperation request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateImportOperationResponder(resp *http.Response) (result ImportExportResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be operated on (updated or created). +// parameters - the required parameters for creating or updating a database. +func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (*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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) CreateOrUpdateSender(req *http.Request) (future DatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be deleted. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(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 = "2014-04-01" + 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}/databases/{databaseName}", 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 DatabasesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Export exports a database to a bacpac. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be exported. +// parameters - the required parameters for exporting a database. +func (client DatabasesClient) Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExportRequest) (result DatabasesExportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Export") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Export", err.Error()) + } + + req, err := client.ExportPreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", nil, "Failure preparing request") + return + } + + result, err = client.ExportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", result.Response(), "Failure sending request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabasesClient) ExportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExportRequest) (*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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ExportSender(req *http.Request) (future DatabasesExportFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ExportResponder(resp *http.Response) (result ImportExportResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be retrieved. +// expand - a comma separated list of child objects to expand in the response. Possible properties: +// serviceTierAdvisors, transparentDataEncryption. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, expand string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "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.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, expand 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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByElasticPool gets a database inside of an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to be retrieved. +// databaseName - the name of the database to be retrieved. +func (client DatabasesClient) GetByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.GetByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.GetByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.GetByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// GetByElasticPoolPreparer prepares the GetByElasticPool request. +func (client DatabasesClient) GetByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByElasticPoolSender sends the GetByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByElasticPoolResponder handles the response to the GetByElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetByElasticPoolResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByRecommendedElasticPool gets a database inside of a recommended elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// recommendedElasticPoolName - the name of the elastic pool to be retrieved. +// databaseName - the name of the database to be retrieved. +func (client DatabasesClient) GetByRecommendedElasticPool(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.GetByRecommendedElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByRecommendedElasticPoolPreparer(ctx, resourceGroupName, serverName, recommendedElasticPoolName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByRecommendedElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.GetByRecommendedElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByRecommendedElasticPool", resp, "Failure sending request") + return + } + + result, err = client.GetByRecommendedElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "GetByRecommendedElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// GetByRecommendedElasticPoolPreparer prepares the GetByRecommendedElasticPool request. +func (client DatabasesClient) GetByRecommendedElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "recommendedElasticPoolName": autorest.Encode("path", recommendedElasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/recommendedElasticPools/{recommendedElasticPoolName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByRecommendedElasticPoolSender sends the GetByRecommendedElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetByRecommendedElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByRecommendedElasticPoolResponder handles the response to the GetByRecommendedElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetByRecommendedElasticPoolResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Import imports a bacpac into a new database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the required parameters for importing a Bacpac into a database. +func (client DatabasesClient) Import(ctx context.Context, resourceGroupName string, serverName string, parameters ImportRequest) (result DatabasesImportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Import") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MaxSizeBytes", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Import", err.Error()) + } + + req, err := client.ImportPreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", nil, "Failure preparing request") + return + } + + result, err = client.ImportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Import", result.Response(), "Failure sending request") + return + } + + return +} + +// ImportPreparer prepares the Import request. +func (client DatabasesClient) ImportPreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ImportRequest) (*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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImportSender sends the Import request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ImportSender(req *http.Request) (future DatabasesImportFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ImportResponder handles the response to the Import request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ImportResponder(resp *http.Response) (result ImportExportResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByElasticPool returns a list of databases in an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to be retrieved. +func (client DatabasesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client DatabasesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRecommendedElasticPool returns a list of databases inside a recommended elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// recommendedElasticPoolName - the name of the recommended elastic pool to be retrieved. +func (client DatabasesClient) ListByRecommendedElasticPool(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (result DatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByRecommendedElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByRecommendedElasticPoolPreparer(ctx, resourceGroupName, serverName, recommendedElasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByRecommendedElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRecommendedElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByRecommendedElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByRecommendedElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByRecommendedElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByRecommendedElasticPoolPreparer prepares the ListByRecommendedElasticPool request. +func (client DatabasesClient) ListByRecommendedElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recommendedElasticPoolName": autorest.Encode("path", recommendedElasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/recommendedElasticPools/{recommendedElasticPoolName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRecommendedElasticPoolSender sends the ListByRecommendedElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByRecommendedElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRecommendedElasticPoolResponder handles the response to the ListByRecommendedElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByRecommendedElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of databases in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// expand - a comma separated list of child objects to expand in the response. Possible properties: +// serviceTierAdvisors, transparentDataEncryption. +// filter - an OData filter expression that describes a subset of databases to return. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, expand string, filter string) (result DatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, expand, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, expand string, filter 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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases", 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 DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions returns database metric definitions. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result MetricDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabasesClient) ListMetricDefinitionsPreparer(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 = "2014-04-01" + 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}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns database metrics. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// filter - an OData filter expression that describes a subset of metrics to return. +func (client DatabasesClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabasesClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter 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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "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}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Pause pauses a data warehouse. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the data warehouse to pause. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Pause") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PausePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "Failure preparing request") + return + } + + result, err = client.PauseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", result.Response(), "Failure sending request") + return + } + + return +} + +// PausePreparer prepares the Pause request. +func (client DatabasesClient) PausePreparer(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 = "2014-04-01" + 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}/databases/{databaseName}/pause", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PauseSender sends the Pause request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) PauseSender(req *http.Request) (future DatabasesPauseFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// PauseResponder handles the response to the Pause request. The method always +// closes the http.Response Body. +func (client DatabasesClient) PauseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a data warehouse. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the data warehouse to resume. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Resume") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ResumePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "Failure preparing request") + return + } + + result, err = client.ResumeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", result.Response(), "Failure sending request") + return + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client DatabasesClient) ResumePreparer(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 = "2014-04-01" + 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}/databases/{databaseName}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ResumeSender(req *http.Request) (future DatabasesResumeFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ResumeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be updated. +// parameters - the required parameters for updating a database. +func (client DatabasesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (result DatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (*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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) UpdateSender(req *http.Request) (future DatabasesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/databasethreatdetectionpolicies.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/databasethreatdetectionpolicies.go new file mode 100644 index 000000000000..5034e53cfadb --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databasethreatdetectionpolicies.go @@ -0,0 +1,198 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseThreatDetectionPoliciesClient 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 DatabaseThreatDetectionPoliciesClient struct { + BaseClient +} + +// NewDatabaseThreatDetectionPoliciesClient creates an instance of the DatabaseThreatDetectionPoliciesClient client. +func NewDatabaseThreatDetectionPoliciesClient(subscriptionID string) DatabaseThreatDetectionPoliciesClient { + return NewDatabaseThreatDetectionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseThreatDetectionPoliciesClientWithBaseURI creates an instance of the DatabaseThreatDetectionPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDatabaseThreatDetectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseThreatDetectionPoliciesClient { + return DatabaseThreatDetectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's threat detection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which database Threat Detection policy is defined. +// parameters - the database Threat Detection policy. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (result DatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseThreatDetectionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "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.DatabaseThreatDetectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", 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 DatabaseThreatDetectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's threat detection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which database Threat Detection policy is defined. +func (client DatabaseThreatDetectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseThreatDetectionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "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.DatabaseThreatDetectionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseThreatDetectionPoliciesClient) 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), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/securityAlertPolicies/{securityAlertPolicyName}", 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 DatabaseThreatDetectionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) GetResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseusages.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseusages.go new file mode 100644 index 000000000000..157fddb468b6 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseusages.go @@ -0,0 +1,112 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseUsagesClient 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 DatabaseUsagesClient struct { + BaseClient +} + +// NewDatabaseUsagesClient creates an instance of the DatabaseUsagesClient client. +func NewDatabaseUsagesClient(subscriptionID string) DatabaseUsagesClient { + return NewDatabaseUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseUsagesClientWithBaseURI creates an instance of the DatabaseUsagesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseUsagesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseUsagesClient { + return DatabaseUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase returns database usages. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseUsagesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseUsagesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseUsagesClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseUsagesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseUsagesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingpolicies.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingpolicies.go new file mode 100644 index 000000000000..bd6726530f7e --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingpolicies.go @@ -0,0 +1,199 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DataMaskingPoliciesClient 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 DataMaskingPoliciesClient struct { + BaseClient +} + +// NewDataMaskingPoliciesClient creates an instance of the DataMaskingPoliciesClient client. +func NewDataMaskingPoliciesClient(subscriptionID string) DataMaskingPoliciesClient { + return NewDataMaskingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataMaskingPoliciesClientWithBaseURI creates an instance of the DataMaskingPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataMaskingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingPoliciesClient { + return DataMaskingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking policy +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - parameters for creating or updating a data masking policy. +func (client DataMaskingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DataMaskingPolicy) (result DataMaskingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "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.DataMaskingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataMaskingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DataMaskingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}", 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 DataMaskingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database data masking policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DataMaskingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "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.DataMaskingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataMaskingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/dataMaskingPolicies/{dataMaskingPolicyName}", 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 DataMaskingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) GetResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingrules.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingrules.go new file mode 100644 index 000000000000..eae0c8e07f66 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingrules.go @@ -0,0 +1,212 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataMaskingRulesClient 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 DataMaskingRulesClient struct { + BaseClient +} + +// NewDataMaskingRulesClient creates an instance of the DataMaskingRulesClient client. +func NewDataMaskingRulesClient(subscriptionID string) DataMaskingRulesClient { + return NewDataMaskingRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataMaskingRulesClientWithBaseURI creates an instance of the DataMaskingRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataMaskingRulesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingRulesClient { + return DataMaskingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// dataMaskingRuleName - the name of the data masking rule. +// parameters - the required parameters for creating or updating a data masking rule. +func (client DataMaskingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (result DataMaskingRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties.SchemaName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DataMaskingRuleProperties.TableName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DataMaskingRuleProperties.ColumnName", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.DataMaskingRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, dataMaskingRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "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.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataMaskingRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "dataMaskingRuleName": autorest.Encode("path", dataMaskingRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", 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 DataMaskingRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database data masking rules. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DataMaskingRulesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingRuleListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingRulesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DataMaskingRulesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DataMaskingRulesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) ListByDatabaseResponder(resp *http.Response) (result DataMaskingRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpoolactivities.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpoolactivities.go new file mode 100644 index 000000000000..441f57b95c41 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpoolactivities.go @@ -0,0 +1,113 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ElasticPoolActivitiesClient 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 ElasticPoolActivitiesClient struct { + BaseClient +} + +// NewElasticPoolActivitiesClient creates an instance of the ElasticPoolActivitiesClient client. +func NewElasticPoolActivitiesClient(subscriptionID string) ElasticPoolActivitiesClient { + return NewElasticPoolActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolActivitiesClientWithBaseURI creates an instance of the ElasticPoolActivitiesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewElasticPoolActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolActivitiesClient { + return ElasticPoolActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns elastic pool activities. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool for which to get the current activity. +func (client ElasticPoolActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolActivitiesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/elasticPoolActivity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpooldatabaseactivities.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpooldatabaseactivities.go new file mode 100644 index 000000000000..ea65995b62c9 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpooldatabaseactivities.go @@ -0,0 +1,113 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ElasticPoolDatabaseActivitiesClient 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 ElasticPoolDatabaseActivitiesClient struct { + BaseClient +} + +// NewElasticPoolDatabaseActivitiesClient creates an instance of the ElasticPoolDatabaseActivitiesClient client. +func NewElasticPoolDatabaseActivitiesClient(subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return NewElasticPoolDatabaseActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolDatabaseActivitiesClientWithBaseURI creates an instance of the ElasticPoolDatabaseActivitiesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewElasticPoolDatabaseActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return ElasticPoolDatabaseActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns activity on databases inside of an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolDatabaseActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolDatabaseActivitiesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolDatabaseActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpools.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpools.go new file mode 100644 index 000000000000..56d4227bd513 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpools.go @@ -0,0 +1,598 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ElasticPoolsClient 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 ElasticPoolsClient struct { + BaseClient +} + +// NewElasticPoolsClient creates an instance of the ElasticPoolsClient client. +func NewElasticPoolsClient(subscriptionID string) ElasticPoolsClient { + return NewElasticPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolsClientWithBaseURI creates an instance of the ElasticPoolsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new elastic pool or updates an existing elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to be operated on (updated or created). +// parameters - the required parameters for creating or updating an elastic pool. +func (client ElasticPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (result ElasticPoolsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ElasticPoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) CreateOrUpdateSender(req *http.Request) (future ElasticPoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to be deleted. +func (client ElasticPoolsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ElasticPoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to be retrieved. +func (client ElasticPoolsClient) Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "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.ElasticPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ElasticPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of elastic pools in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ElasticPoolListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ElasticPoolsClient) 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 = "2014-04-01" + 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}/elasticPools", 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 ElasticPoolsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions returns elastic pool metric definitions. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result MetricDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client ElasticPoolsClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns elastic pool metrics. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +// filter - an OData filter expression that describes a subset of metrics to return. +func (client ElasticPoolsClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, elasticPoolName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client ElasticPoolsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to be updated. +// parameters - the required parameters for updating an elastic pool. +func (client ElasticPoolsClient) Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (result ElasticPoolsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ElasticPoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) UpdateSender(req *http.Request) (future ElasticPoolsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/encryptionprotectors.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/encryptionprotectors.go new file mode 100644 index 000000000000..14c45a85d0a3 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/encryptionprotectors.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// EncryptionProtectorsClient 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 EncryptionProtectorsClient struct { + BaseClient +} + +// NewEncryptionProtectorsClient creates an instance of the EncryptionProtectorsClient client. +func NewEncryptionProtectorsClient(subscriptionID string) EncryptionProtectorsClient { + return NewEncryptionProtectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEncryptionProtectorsClientWithBaseURI creates an instance of the EncryptionProtectorsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) EncryptionProtectorsClient { + return EncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested encryption protector resource state. +func (client EncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (result EncryptionProtectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client EncryptionProtectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "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, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}", 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 EncryptionProtectorsClient) CreateOrUpdateSender(req *http.Request) (future EncryptionProtectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) CreateOrUpdateResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server encryption protector. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client EncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "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.EncryptionProtectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EncryptionProtectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "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}/encryptionProtector/{encryptionProtectorName}", 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 EncryptionProtectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) GetResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server encryption protectors +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client EncryptionProtectorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.ListByServer") + defer func() { + sc := -1 + if result.eplr.Response.Response != nil { + sc = result.eplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.eplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.eplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.eplr.hasNextLink() && result.eplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client EncryptionProtectorsClient) 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 = "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}/encryptionProtector", 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 EncryptionProtectorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) ListByServerResponder(resp *http.Response) (result EncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + 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 EncryptionProtectorsClient) listByServerNextResults(ctx context.Context, lastResults EncryptionProtectorListResult) (result EncryptionProtectorListResult, err error) { + req, err := lastResults.encryptionProtectorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "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.EncryptionProtectorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client EncryptionProtectorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Revalidate revalidates an existing encryption protector. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client EncryptionProtectorsClient) Revalidate(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorsRevalidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.Revalidate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RevalidatePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Revalidate", nil, "Failure preparing request") + return + } + + result, err = client.RevalidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Revalidate", result.Response(), "Failure sending request") + return + } + + return +} + +// RevalidatePreparer prepares the Revalidate request. +func (client EncryptionProtectorsClient) RevalidatePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "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.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevalidateSender sends the Revalidate request. The method will close the +// http.Response Body if it receives an error. +func (client EncryptionProtectorsClient) RevalidateSender(req *http.Request) (future EncryptionProtectorsRevalidateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RevalidateResponder handles the response to the Revalidate request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) RevalidateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/enums.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/enums.go new file mode 100644 index 000000000000..3f357397e296 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/enums.go @@ -0,0 +1,1060 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AuthenticationType enumerates the values for authentication type. +type AuthenticationType string + +const ( + // ADPassword ... + ADPassword AuthenticationType = "ADPassword" + // SQL ... + SQL AuthenticationType = "SQL" +) + +// PossibleAuthenticationTypeValues returns an array of possible values for the AuthenticationType const type. +func PossibleAuthenticationTypeValues() []AuthenticationType { + return []AuthenticationType{ADPassword, SQL} +} + +// BlobAuditingPolicyState enumerates the values for blob auditing policy state. +type BlobAuditingPolicyState string + +const ( + // Disabled ... + Disabled BlobAuditingPolicyState = "Disabled" + // Enabled ... + Enabled BlobAuditingPolicyState = "Enabled" +) + +// PossibleBlobAuditingPolicyStateValues returns an array of possible values for the BlobAuditingPolicyState const type. +func PossibleBlobAuditingPolicyStateValues() []BlobAuditingPolicyState { + return []BlobAuditingPolicyState{Disabled, Enabled} +} + +// CapabilityStatus enumerates the values for capability status. +type CapabilityStatus string + +const ( + // CapabilityStatusAvailable ... + CapabilityStatusAvailable CapabilityStatus = "Available" + // CapabilityStatusDefault ... + CapabilityStatusDefault CapabilityStatus = "Default" + // CapabilityStatusDisabled ... + CapabilityStatusDisabled CapabilityStatus = "Disabled" + // CapabilityStatusVisible ... + CapabilityStatusVisible CapabilityStatus = "Visible" +) + +// PossibleCapabilityStatusValues returns an array of possible values for the CapabilityStatus const type. +func PossibleCapabilityStatusValues() []CapabilityStatus { + return []CapabilityStatus{CapabilityStatusAvailable, CapabilityStatusDefault, CapabilityStatusDisabled, CapabilityStatusVisible} +} + +// CheckNameAvailabilityReason enumerates the values for check name availability reason. +type CheckNameAvailabilityReason string + +const ( + // AlreadyExists ... + AlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + // Invalid ... + Invalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns an array of possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{AlreadyExists, Invalid} +} + +// CreateMode enumerates the values for create mode. +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" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{Copy, Default, NonReadableSecondary, OnlineSecondary, PointInTimeRestore, Recovery, Restore, RestoreLongTermRetentionBackup} +} + +// DatabaseEdition enumerates the values for database edition. +type DatabaseEdition string + +const ( + // Basic ... + Basic DatabaseEdition = "Basic" + // Business ... + Business DatabaseEdition = "Business" + // BusinessCritical ... + BusinessCritical DatabaseEdition = "BusinessCritical" + // DataWarehouse ... + DataWarehouse DatabaseEdition = "DataWarehouse" + // Free ... + Free DatabaseEdition = "Free" + // GeneralPurpose ... + GeneralPurpose DatabaseEdition = "GeneralPurpose" + // Hyperscale ... + Hyperscale DatabaseEdition = "Hyperscale" + // Premium ... + Premium DatabaseEdition = "Premium" + // PremiumRS ... + PremiumRS DatabaseEdition = "PremiumRS" + // Standard ... + Standard DatabaseEdition = "Standard" + // Stretch ... + Stretch DatabaseEdition = "Stretch" + // System ... + System DatabaseEdition = "System" + // System2 ... + System2 DatabaseEdition = "System2" + // Web ... + Web DatabaseEdition = "Web" +) + +// PossibleDatabaseEditionValues returns an array of possible values for the DatabaseEdition const type. +func PossibleDatabaseEditionValues() []DatabaseEdition { + return []DatabaseEdition{Basic, Business, BusinessCritical, DataWarehouse, Free, GeneralPurpose, Hyperscale, Premium, PremiumRS, Standard, Stretch, System, System2, Web} +} + +// DataMaskingFunction enumerates the values for data masking function. +type DataMaskingFunction string + +const ( + // DataMaskingFunctionCCN ... + DataMaskingFunctionCCN DataMaskingFunction = "CCN" + // DataMaskingFunctionDefault ... + DataMaskingFunctionDefault DataMaskingFunction = "Default" + // DataMaskingFunctionEmail ... + DataMaskingFunctionEmail DataMaskingFunction = "Email" + // DataMaskingFunctionNumber ... + DataMaskingFunctionNumber DataMaskingFunction = "Number" + // DataMaskingFunctionSSN ... + DataMaskingFunctionSSN DataMaskingFunction = "SSN" + // DataMaskingFunctionText ... + DataMaskingFunctionText DataMaskingFunction = "Text" +) + +// PossibleDataMaskingFunctionValues returns an array of possible values for the DataMaskingFunction const type. +func PossibleDataMaskingFunctionValues() []DataMaskingFunction { + return []DataMaskingFunction{DataMaskingFunctionCCN, DataMaskingFunctionDefault, DataMaskingFunctionEmail, DataMaskingFunctionNumber, DataMaskingFunctionSSN, DataMaskingFunctionText} +} + +// DataMaskingRuleState enumerates the values for data masking rule state. +type DataMaskingRuleState string + +const ( + // DataMaskingRuleStateDisabled ... + DataMaskingRuleStateDisabled DataMaskingRuleState = "Disabled" + // DataMaskingRuleStateEnabled ... + DataMaskingRuleStateEnabled DataMaskingRuleState = "Enabled" +) + +// PossibleDataMaskingRuleStateValues returns an array of possible values for the DataMaskingRuleState const type. +func PossibleDataMaskingRuleStateValues() []DataMaskingRuleState { + return []DataMaskingRuleState{DataMaskingRuleStateDisabled, DataMaskingRuleStateEnabled} +} + +// DataMaskingState enumerates the values for data masking state. +type DataMaskingState string + +const ( + // DataMaskingStateDisabled ... + DataMaskingStateDisabled DataMaskingState = "Disabled" + // DataMaskingStateEnabled ... + DataMaskingStateEnabled DataMaskingState = "Enabled" +) + +// PossibleDataMaskingStateValues returns an array of possible values for the DataMaskingState const type. +func PossibleDataMaskingStateValues() []DataMaskingState { + return []DataMaskingState{DataMaskingStateDisabled, DataMaskingStateEnabled} +} + +// ElasticPoolEdition enumerates the values for elastic pool edition. +type ElasticPoolEdition string + +const ( + // ElasticPoolEditionBasic ... + ElasticPoolEditionBasic ElasticPoolEdition = "Basic" + // ElasticPoolEditionBusinessCritical ... + ElasticPoolEditionBusinessCritical ElasticPoolEdition = "BusinessCritical" + // ElasticPoolEditionGeneralPurpose ... + ElasticPoolEditionGeneralPurpose ElasticPoolEdition = "GeneralPurpose" + // ElasticPoolEditionPremium ... + ElasticPoolEditionPremium ElasticPoolEdition = "Premium" + // ElasticPoolEditionStandard ... + ElasticPoolEditionStandard ElasticPoolEdition = "Standard" +) + +// PossibleElasticPoolEditionValues returns an array of possible values for the ElasticPoolEdition const type. +func PossibleElasticPoolEditionValues() []ElasticPoolEdition { + return []ElasticPoolEdition{ElasticPoolEditionBasic, ElasticPoolEditionBusinessCritical, ElasticPoolEditionGeneralPurpose, ElasticPoolEditionPremium, ElasticPoolEditionStandard} +} + +// ElasticPoolState enumerates the values for elastic pool state. +type ElasticPoolState string + +const ( + // ElasticPoolStateCreating ... + ElasticPoolStateCreating ElasticPoolState = "Creating" + // ElasticPoolStateDisabled ... + ElasticPoolStateDisabled ElasticPoolState = "Disabled" + // ElasticPoolStateReady ... + ElasticPoolStateReady ElasticPoolState = "Ready" +) + +// PossibleElasticPoolStateValues returns an array of possible values for the ElasticPoolState const type. +func PossibleElasticPoolStateValues() []ElasticPoolState { + return []ElasticPoolState{ElasticPoolStateCreating, ElasticPoolStateDisabled, ElasticPoolStateReady} +} + +// FailoverGroupReplicationRole enumerates the values for failover group replication role. +type FailoverGroupReplicationRole string + +const ( + // Primary ... + Primary FailoverGroupReplicationRole = "Primary" + // Secondary ... + Secondary FailoverGroupReplicationRole = "Secondary" +) + +// PossibleFailoverGroupReplicationRoleValues returns an array of possible values for the FailoverGroupReplicationRole const type. +func PossibleFailoverGroupReplicationRoleValues() []FailoverGroupReplicationRole { + return []FailoverGroupReplicationRole{Primary, Secondary} +} + +// GeoBackupPolicyState enumerates the values for geo backup policy state. +type GeoBackupPolicyState string + +const ( + // GeoBackupPolicyStateDisabled ... + GeoBackupPolicyStateDisabled GeoBackupPolicyState = "Disabled" + // GeoBackupPolicyStateEnabled ... + GeoBackupPolicyStateEnabled GeoBackupPolicyState = "Enabled" +) + +// PossibleGeoBackupPolicyStateValues returns an array of possible values for the GeoBackupPolicyState const type. +func PossibleGeoBackupPolicyStateValues() []GeoBackupPolicyState { + return []GeoBackupPolicyState{GeoBackupPolicyStateDisabled, GeoBackupPolicyStateEnabled} +} + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // None ... + None IdentityType = "None" + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" + // SystemAssignedUserAssigned ... + SystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" + // UserAssigned ... + UserAssigned IdentityType = "UserAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{None, SystemAssigned, SystemAssignedUserAssigned, UserAssigned} +} + +// ManagedInstanceLicenseType enumerates the values for managed instance license type. +type ManagedInstanceLicenseType string + +const ( + // BasePrice ... + BasePrice ManagedInstanceLicenseType = "BasePrice" + // LicenseIncluded ... + LicenseIncluded ManagedInstanceLicenseType = "LicenseIncluded" +) + +// PossibleManagedInstanceLicenseTypeValues returns an array of possible values for the ManagedInstanceLicenseType const type. +func PossibleManagedInstanceLicenseTypeValues() []ManagedInstanceLicenseType { + return []ManagedInstanceLicenseType{BasePrice, LicenseIncluded} +} + +// ManagedInstanceProxyOverride enumerates the values for managed instance proxy override. +type ManagedInstanceProxyOverride string + +const ( + // ManagedInstanceProxyOverrideDefault ... + ManagedInstanceProxyOverrideDefault ManagedInstanceProxyOverride = "Default" + // ManagedInstanceProxyOverrideProxy ... + ManagedInstanceProxyOverrideProxy ManagedInstanceProxyOverride = "Proxy" + // ManagedInstanceProxyOverrideRedirect ... + ManagedInstanceProxyOverrideRedirect ManagedInstanceProxyOverride = "Redirect" +) + +// PossibleManagedInstanceProxyOverrideValues returns an array of possible values for the ManagedInstanceProxyOverride const type. +func PossibleManagedInstanceProxyOverrideValues() []ManagedInstanceProxyOverride { + return []ManagedInstanceProxyOverride{ManagedInstanceProxyOverrideDefault, ManagedInstanceProxyOverrideProxy, ManagedInstanceProxyOverrideRedirect} +} + +// ManagedServerCreateMode enumerates the values for managed server create mode. +type ManagedServerCreateMode string + +const ( + // ManagedServerCreateModeDefault ... + ManagedServerCreateModeDefault ManagedServerCreateMode = "Default" + // ManagedServerCreateModePointInTimeRestore ... + ManagedServerCreateModePointInTimeRestore ManagedServerCreateMode = "PointInTimeRestore" +) + +// PossibleManagedServerCreateModeValues returns an array of possible values for the ManagedServerCreateMode const type. +func PossibleManagedServerCreateModeValues() []ManagedServerCreateMode { + return []ManagedServerCreateMode{ManagedServerCreateModeDefault, ManagedServerCreateModePointInTimeRestore} +} + +// MaxSizeUnits enumerates the values for max size units. +type MaxSizeUnits string + +const ( + // Gigabytes ... + Gigabytes MaxSizeUnits = "Gigabytes" + // Megabytes ... + Megabytes MaxSizeUnits = "Megabytes" + // Petabytes ... + Petabytes MaxSizeUnits = "Petabytes" + // Terabytes ... + Terabytes MaxSizeUnits = "Terabytes" +) + +// PossibleMaxSizeUnitsValues returns an array of possible values for the MaxSizeUnits const type. +func PossibleMaxSizeUnitsValues() []MaxSizeUnits { + return []MaxSizeUnits{Gigabytes, Megabytes, Petabytes, Terabytes} +} + +// OperationOrigin enumerates the values for operation origin. +type OperationOrigin string + +const ( + // OperationOriginSystem ... + OperationOriginSystem OperationOrigin = "system" + // OperationOriginUser ... + OperationOriginUser OperationOrigin = "user" +) + +// PossibleOperationOriginValues returns an array of possible values for the OperationOrigin const type. +func PossibleOperationOriginValues() []OperationOrigin { + return []OperationOrigin{OperationOriginSystem, OperationOriginUser} +} + +// PerformanceLevelUnit enumerates the values for performance level unit. +type PerformanceLevelUnit string + +const ( + // DTU ... + DTU PerformanceLevelUnit = "DTU" +) + +// PossiblePerformanceLevelUnitValues returns an array of possible values for the PerformanceLevelUnit const type. +func PossiblePerformanceLevelUnitValues() []PerformanceLevelUnit { + return []PerformanceLevelUnit{DTU} +} + +// PrimaryAggregationType enumerates the values for primary aggregation type. +type PrimaryAggregationType string + +const ( + // PrimaryAggregationTypeAverage ... + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + // PrimaryAggregationTypeCount ... + PrimaryAggregationTypeCount PrimaryAggregationType = "Count" + // PrimaryAggregationTypeMaximum ... + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + // PrimaryAggregationTypeMinimum ... + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + // PrimaryAggregationTypeNone ... + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + // PrimaryAggregationTypeTotal ... + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" +) + +// PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. +func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { + return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeCount, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} +} + +// ReadOnlyEndpointFailoverPolicy enumerates the values for read only endpoint failover policy. +type ReadOnlyEndpointFailoverPolicy string + +const ( + // ReadOnlyEndpointFailoverPolicyDisabled ... + ReadOnlyEndpointFailoverPolicyDisabled ReadOnlyEndpointFailoverPolicy = "Disabled" + // ReadOnlyEndpointFailoverPolicyEnabled ... + ReadOnlyEndpointFailoverPolicyEnabled ReadOnlyEndpointFailoverPolicy = "Enabled" +) + +// PossibleReadOnlyEndpointFailoverPolicyValues returns an array of possible values for the ReadOnlyEndpointFailoverPolicy const type. +func PossibleReadOnlyEndpointFailoverPolicyValues() []ReadOnlyEndpointFailoverPolicy { + return []ReadOnlyEndpointFailoverPolicy{ReadOnlyEndpointFailoverPolicyDisabled, ReadOnlyEndpointFailoverPolicyEnabled} +} + +// ReadScale enumerates the values for read scale. +type ReadScale string + +const ( + // ReadScaleDisabled ... + ReadScaleDisabled ReadScale = "Disabled" + // ReadScaleEnabled ... + ReadScaleEnabled ReadScale = "Enabled" +) + +// PossibleReadScaleValues returns an array of possible values for the ReadScale const type. +func PossibleReadScaleValues() []ReadScale { + return []ReadScale{ReadScaleDisabled, ReadScaleEnabled} +} + +// ReadWriteEndpointFailoverPolicy enumerates the values for read write endpoint failover policy. +type ReadWriteEndpointFailoverPolicy string + +const ( + // Automatic ... + Automatic ReadWriteEndpointFailoverPolicy = "Automatic" + // Manual ... + Manual ReadWriteEndpointFailoverPolicy = "Manual" +) + +// PossibleReadWriteEndpointFailoverPolicyValues returns an array of possible values for the ReadWriteEndpointFailoverPolicy const type. +func PossibleReadWriteEndpointFailoverPolicyValues() []ReadWriteEndpointFailoverPolicy { + return []ReadWriteEndpointFailoverPolicy{Automatic, Manual} +} + +// RecommendedIndexAction enumerates the values for recommended index action. +type RecommendedIndexAction string + +const ( + // Create ... + Create RecommendedIndexAction = "Create" + // Drop ... + Drop RecommendedIndexAction = "Drop" + // Rebuild ... + Rebuild RecommendedIndexAction = "Rebuild" +) + +// PossibleRecommendedIndexActionValues returns an array of possible values for the RecommendedIndexAction const type. +func PossibleRecommendedIndexActionValues() []RecommendedIndexAction { + return []RecommendedIndexAction{Create, Drop, Rebuild} +} + +// RecommendedIndexState enumerates the values for recommended index state. +type RecommendedIndexState string + +const ( + // 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" +) + +// PossibleRecommendedIndexStateValues returns an array of possible values for the RecommendedIndexState const type. +func PossibleRecommendedIndexStateValues() []RecommendedIndexState { + return []RecommendedIndexState{Active, Blocked, Executing, Expired, Ignored, Pending, PendingRevert, Reverted, Reverting, Success, Verifying} +} + +// RecommendedIndexType enumerates the values for recommended index type. +type RecommendedIndexType string + +const ( + // CLUSTERED ... + CLUSTERED RecommendedIndexType = "CLUSTERED" + // CLUSTEREDCOLUMNSTORE ... + CLUSTEREDCOLUMNSTORE RecommendedIndexType = "CLUSTERED COLUMNSTORE" + // COLUMNSTORE ... + COLUMNSTORE RecommendedIndexType = "COLUMNSTORE" + // NONCLUSTERED ... + NONCLUSTERED RecommendedIndexType = "NONCLUSTERED" +) + +// PossibleRecommendedIndexTypeValues returns an array of possible values for the RecommendedIndexType const type. +func PossibleRecommendedIndexTypeValues() []RecommendedIndexType { + return []RecommendedIndexType{CLUSTERED, CLUSTEREDCOLUMNSTORE, COLUMNSTORE, NONCLUSTERED} +} + +// ReplicationRole enumerates the values for replication role. +type ReplicationRole string + +const ( + // ReplicationRoleCopy ... + ReplicationRoleCopy ReplicationRole = "Copy" + // ReplicationRoleNonReadableSecondary ... + ReplicationRoleNonReadableSecondary ReplicationRole = "NonReadableSecondary" + // ReplicationRolePrimary ... + ReplicationRolePrimary ReplicationRole = "Primary" + // ReplicationRoleSecondary ... + ReplicationRoleSecondary ReplicationRole = "Secondary" + // ReplicationRoleSource ... + ReplicationRoleSource ReplicationRole = "Source" +) + +// PossibleReplicationRoleValues returns an array of possible values for the ReplicationRole const type. +func PossibleReplicationRoleValues() []ReplicationRole { + return []ReplicationRole{ReplicationRoleCopy, ReplicationRoleNonReadableSecondary, ReplicationRolePrimary, ReplicationRoleSecondary, ReplicationRoleSource} +} + +// ReplicationState enumerates the values for replication state. +type ReplicationState string + +const ( + // CATCHUP ... + CATCHUP ReplicationState = "CATCH_UP" + // PENDING ... + PENDING ReplicationState = "PENDING" + // SEEDING ... + SEEDING ReplicationState = "SEEDING" + // SUSPENDED ... + SUSPENDED ReplicationState = "SUSPENDED" +) + +// PossibleReplicationStateValues returns an array of possible values for the ReplicationState const type. +func PossibleReplicationStateValues() []ReplicationState { + return []ReplicationState{CATCHUP, PENDING, SEEDING, SUSPENDED} +} + +// RestorePointType enumerates the values for restore point type. +type RestorePointType string + +const ( + // CONTINUOUS ... + CONTINUOUS RestorePointType = "CONTINUOUS" + // DISCRETE ... + DISCRETE RestorePointType = "DISCRETE" +) + +// PossibleRestorePointTypeValues returns an array of possible values for the RestorePointType const type. +func PossibleRestorePointTypeValues() []RestorePointType { + return []RestorePointType{CONTINUOUS, DISCRETE} +} + +// SampleName enumerates the values for sample name. +type SampleName string + +const ( + // AdventureWorksLT ... + AdventureWorksLT SampleName = "AdventureWorksLT" +) + +// PossibleSampleNameValues returns an array of possible values for the SampleName const type. +func PossibleSampleNameValues() []SampleName { + return []SampleName{AdventureWorksLT} +} + +// SecurityAlertPolicyEmailAccountAdmins enumerates the values for security alert policy email account admins. +type SecurityAlertPolicyEmailAccountAdmins string + +const ( + // SecurityAlertPolicyEmailAccountAdminsDisabled ... + SecurityAlertPolicyEmailAccountAdminsDisabled SecurityAlertPolicyEmailAccountAdmins = "Disabled" + // SecurityAlertPolicyEmailAccountAdminsEnabled ... + SecurityAlertPolicyEmailAccountAdminsEnabled SecurityAlertPolicyEmailAccountAdmins = "Enabled" +) + +// PossibleSecurityAlertPolicyEmailAccountAdminsValues returns an array of possible values for the SecurityAlertPolicyEmailAccountAdmins const type. +func PossibleSecurityAlertPolicyEmailAccountAdminsValues() []SecurityAlertPolicyEmailAccountAdmins { + return []SecurityAlertPolicyEmailAccountAdmins{SecurityAlertPolicyEmailAccountAdminsDisabled, SecurityAlertPolicyEmailAccountAdminsEnabled} +} + +// SecurityAlertPolicyState enumerates the values for security alert policy state. +type SecurityAlertPolicyState string + +const ( + // SecurityAlertPolicyStateDisabled ... + SecurityAlertPolicyStateDisabled SecurityAlertPolicyState = "Disabled" + // SecurityAlertPolicyStateEnabled ... + SecurityAlertPolicyStateEnabled SecurityAlertPolicyState = "Enabled" + // SecurityAlertPolicyStateNew ... + SecurityAlertPolicyStateNew SecurityAlertPolicyState = "New" +) + +// PossibleSecurityAlertPolicyStateValues returns an array of possible values for the SecurityAlertPolicyState const type. +func PossibleSecurityAlertPolicyStateValues() []SecurityAlertPolicyState { + return []SecurityAlertPolicyState{SecurityAlertPolicyStateDisabled, SecurityAlertPolicyStateEnabled, SecurityAlertPolicyStateNew} +} + +// SecurityAlertPolicyUseServerDefault enumerates the values for security alert policy use server default. +type SecurityAlertPolicyUseServerDefault string + +const ( + // SecurityAlertPolicyUseServerDefaultDisabled ... + SecurityAlertPolicyUseServerDefaultDisabled SecurityAlertPolicyUseServerDefault = "Disabled" + // SecurityAlertPolicyUseServerDefaultEnabled ... + SecurityAlertPolicyUseServerDefaultEnabled SecurityAlertPolicyUseServerDefault = "Enabled" +) + +// PossibleSecurityAlertPolicyUseServerDefaultValues returns an array of possible values for the SecurityAlertPolicyUseServerDefault const type. +func PossibleSecurityAlertPolicyUseServerDefaultValues() []SecurityAlertPolicyUseServerDefault { + return []SecurityAlertPolicyUseServerDefault{SecurityAlertPolicyUseServerDefaultDisabled, SecurityAlertPolicyUseServerDefaultEnabled} +} + +// ServerConnectionType enumerates the values for server connection type. +type ServerConnectionType string + +const ( + // ServerConnectionTypeDefault ... + ServerConnectionTypeDefault ServerConnectionType = "Default" + // ServerConnectionTypeProxy ... + ServerConnectionTypeProxy ServerConnectionType = "Proxy" + // ServerConnectionTypeRedirect ... + ServerConnectionTypeRedirect ServerConnectionType = "Redirect" +) + +// PossibleServerConnectionTypeValues returns an array of possible values for the ServerConnectionType const type. +func PossibleServerConnectionTypeValues() []ServerConnectionType { + return []ServerConnectionType{ServerConnectionTypeDefault, ServerConnectionTypeProxy, ServerConnectionTypeRedirect} +} + +// ServerKeyType enumerates the values for server key type. +type ServerKeyType string + +const ( + // AzureKeyVault ... + AzureKeyVault ServerKeyType = "AzureKeyVault" + // ServiceManaged ... + ServiceManaged ServerKeyType = "ServiceManaged" +) + +// PossibleServerKeyTypeValues returns an array of possible values for the ServerKeyType const type. +func PossibleServerKeyTypeValues() []ServerKeyType { + return []ServerKeyType{AzureKeyVault, ServiceManaged} +} + +// ServiceObjectiveName enumerates the values for service objective name. +type ServiceObjectiveName string + +const ( + // ServiceObjectiveNameBasic ... + ServiceObjectiveNameBasic ServiceObjectiveName = "Basic" + // ServiceObjectiveNameDS100 ... + ServiceObjectiveNameDS100 ServiceObjectiveName = "DS100" + // ServiceObjectiveNameDS1000 ... + ServiceObjectiveNameDS1000 ServiceObjectiveName = "DS1000" + // ServiceObjectiveNameDS1200 ... + ServiceObjectiveNameDS1200 ServiceObjectiveName = "DS1200" + // ServiceObjectiveNameDS1500 ... + ServiceObjectiveNameDS1500 ServiceObjectiveName = "DS1500" + // ServiceObjectiveNameDS200 ... + ServiceObjectiveNameDS200 ServiceObjectiveName = "DS200" + // ServiceObjectiveNameDS2000 ... + ServiceObjectiveNameDS2000 ServiceObjectiveName = "DS2000" + // ServiceObjectiveNameDS300 ... + ServiceObjectiveNameDS300 ServiceObjectiveName = "DS300" + // ServiceObjectiveNameDS400 ... + ServiceObjectiveNameDS400 ServiceObjectiveName = "DS400" + // ServiceObjectiveNameDS500 ... + ServiceObjectiveNameDS500 ServiceObjectiveName = "DS500" + // ServiceObjectiveNameDS600 ... + ServiceObjectiveNameDS600 ServiceObjectiveName = "DS600" + // ServiceObjectiveNameDW100 ... + ServiceObjectiveNameDW100 ServiceObjectiveName = "DW100" + // ServiceObjectiveNameDW1000 ... + ServiceObjectiveNameDW1000 ServiceObjectiveName = "DW1000" + // ServiceObjectiveNameDW10000c ... + ServiceObjectiveNameDW10000c ServiceObjectiveName = "DW10000c" + // ServiceObjectiveNameDW1000c ... + ServiceObjectiveNameDW1000c ServiceObjectiveName = "DW1000c" + // ServiceObjectiveNameDW1200 ... + ServiceObjectiveNameDW1200 ServiceObjectiveName = "DW1200" + // ServiceObjectiveNameDW1500 ... + ServiceObjectiveNameDW1500 ServiceObjectiveName = "DW1500" + // ServiceObjectiveNameDW15000c ... + ServiceObjectiveNameDW15000c ServiceObjectiveName = "DW15000c" + // ServiceObjectiveNameDW1500c ... + ServiceObjectiveNameDW1500c ServiceObjectiveName = "DW1500c" + // ServiceObjectiveNameDW200 ... + ServiceObjectiveNameDW200 ServiceObjectiveName = "DW200" + // ServiceObjectiveNameDW2000 ... + ServiceObjectiveNameDW2000 ServiceObjectiveName = "DW2000" + // ServiceObjectiveNameDW2000c ... + ServiceObjectiveNameDW2000c ServiceObjectiveName = "DW2000c" + // ServiceObjectiveNameDW2500c ... + ServiceObjectiveNameDW2500c ServiceObjectiveName = "DW2500c" + // ServiceObjectiveNameDW300 ... + ServiceObjectiveNameDW300 ServiceObjectiveName = "DW300" + // ServiceObjectiveNameDW3000 ... + ServiceObjectiveNameDW3000 ServiceObjectiveName = "DW3000" + // ServiceObjectiveNameDW30000c ... + ServiceObjectiveNameDW30000c ServiceObjectiveName = "DW30000c" + // ServiceObjectiveNameDW3000c ... + ServiceObjectiveNameDW3000c ServiceObjectiveName = "DW3000c" + // ServiceObjectiveNameDW400 ... + ServiceObjectiveNameDW400 ServiceObjectiveName = "DW400" + // ServiceObjectiveNameDW500 ... + ServiceObjectiveNameDW500 ServiceObjectiveName = "DW500" + // ServiceObjectiveNameDW5000c ... + ServiceObjectiveNameDW5000c ServiceObjectiveName = "DW5000c" + // ServiceObjectiveNameDW600 ... + ServiceObjectiveNameDW600 ServiceObjectiveName = "DW600" + // ServiceObjectiveNameDW6000 ... + ServiceObjectiveNameDW6000 ServiceObjectiveName = "DW6000" + // ServiceObjectiveNameDW6000c ... + ServiceObjectiveNameDW6000c ServiceObjectiveName = "DW6000c" + // ServiceObjectiveNameDW7500c ... + ServiceObjectiveNameDW7500c ServiceObjectiveName = "DW7500c" + // ServiceObjectiveNameElasticPool ... + ServiceObjectiveNameElasticPool ServiceObjectiveName = "ElasticPool" + // ServiceObjectiveNameFree ... + ServiceObjectiveNameFree ServiceObjectiveName = "Free" + // ServiceObjectiveNameP1 ... + ServiceObjectiveNameP1 ServiceObjectiveName = "P1" + // ServiceObjectiveNameP11 ... + ServiceObjectiveNameP11 ServiceObjectiveName = "P11" + // ServiceObjectiveNameP15 ... + ServiceObjectiveNameP15 ServiceObjectiveName = "P15" + // ServiceObjectiveNameP2 ... + ServiceObjectiveNameP2 ServiceObjectiveName = "P2" + // ServiceObjectiveNameP3 ... + ServiceObjectiveNameP3 ServiceObjectiveName = "P3" + // ServiceObjectiveNameP4 ... + ServiceObjectiveNameP4 ServiceObjectiveName = "P4" + // ServiceObjectiveNameP6 ... + ServiceObjectiveNameP6 ServiceObjectiveName = "P6" + // ServiceObjectiveNamePRS1 ... + ServiceObjectiveNamePRS1 ServiceObjectiveName = "PRS1" + // ServiceObjectiveNamePRS2 ... + ServiceObjectiveNamePRS2 ServiceObjectiveName = "PRS2" + // ServiceObjectiveNamePRS4 ... + ServiceObjectiveNamePRS4 ServiceObjectiveName = "PRS4" + // ServiceObjectiveNamePRS6 ... + ServiceObjectiveNamePRS6 ServiceObjectiveName = "PRS6" + // ServiceObjectiveNameS0 ... + ServiceObjectiveNameS0 ServiceObjectiveName = "S0" + // ServiceObjectiveNameS1 ... + ServiceObjectiveNameS1 ServiceObjectiveName = "S1" + // ServiceObjectiveNameS12 ... + ServiceObjectiveNameS12 ServiceObjectiveName = "S12" + // ServiceObjectiveNameS2 ... + ServiceObjectiveNameS2 ServiceObjectiveName = "S2" + // ServiceObjectiveNameS3 ... + ServiceObjectiveNameS3 ServiceObjectiveName = "S3" + // ServiceObjectiveNameS4 ... + ServiceObjectiveNameS4 ServiceObjectiveName = "S4" + // ServiceObjectiveNameS6 ... + ServiceObjectiveNameS6 ServiceObjectiveName = "S6" + // ServiceObjectiveNameS7 ... + ServiceObjectiveNameS7 ServiceObjectiveName = "S7" + // ServiceObjectiveNameS9 ... + ServiceObjectiveNameS9 ServiceObjectiveName = "S9" + // ServiceObjectiveNameSystem ... + ServiceObjectiveNameSystem ServiceObjectiveName = "System" + // ServiceObjectiveNameSystem0 ... + ServiceObjectiveNameSystem0 ServiceObjectiveName = "System0" + // ServiceObjectiveNameSystem1 ... + ServiceObjectiveNameSystem1 ServiceObjectiveName = "System1" + // ServiceObjectiveNameSystem2 ... + ServiceObjectiveNameSystem2 ServiceObjectiveName = "System2" + // ServiceObjectiveNameSystem2L ... + ServiceObjectiveNameSystem2L ServiceObjectiveName = "System2L" + // ServiceObjectiveNameSystem3 ... + ServiceObjectiveNameSystem3 ServiceObjectiveName = "System3" + // ServiceObjectiveNameSystem3L ... + ServiceObjectiveNameSystem3L ServiceObjectiveName = "System3L" + // ServiceObjectiveNameSystem4 ... + ServiceObjectiveNameSystem4 ServiceObjectiveName = "System4" + // ServiceObjectiveNameSystem4L ... + ServiceObjectiveNameSystem4L ServiceObjectiveName = "System4L" +) + +// PossibleServiceObjectiveNameValues returns an array of possible values for the ServiceObjectiveName const type. +func PossibleServiceObjectiveNameValues() []ServiceObjectiveName { + return []ServiceObjectiveName{ServiceObjectiveNameBasic, ServiceObjectiveNameDS100, ServiceObjectiveNameDS1000, ServiceObjectiveNameDS1200, ServiceObjectiveNameDS1500, ServiceObjectiveNameDS200, ServiceObjectiveNameDS2000, ServiceObjectiveNameDS300, ServiceObjectiveNameDS400, ServiceObjectiveNameDS500, ServiceObjectiveNameDS600, ServiceObjectiveNameDW100, ServiceObjectiveNameDW1000, ServiceObjectiveNameDW10000c, ServiceObjectiveNameDW1000c, ServiceObjectiveNameDW1200, ServiceObjectiveNameDW1500, ServiceObjectiveNameDW15000c, ServiceObjectiveNameDW1500c, ServiceObjectiveNameDW200, ServiceObjectiveNameDW2000, ServiceObjectiveNameDW2000c, ServiceObjectiveNameDW2500c, ServiceObjectiveNameDW300, ServiceObjectiveNameDW3000, ServiceObjectiveNameDW30000c, ServiceObjectiveNameDW3000c, ServiceObjectiveNameDW400, ServiceObjectiveNameDW500, ServiceObjectiveNameDW5000c, ServiceObjectiveNameDW600, ServiceObjectiveNameDW6000, ServiceObjectiveNameDW6000c, ServiceObjectiveNameDW7500c, ServiceObjectiveNameElasticPool, ServiceObjectiveNameFree, ServiceObjectiveNameP1, ServiceObjectiveNameP11, ServiceObjectiveNameP15, ServiceObjectiveNameP2, ServiceObjectiveNameP3, ServiceObjectiveNameP4, ServiceObjectiveNameP6, ServiceObjectiveNamePRS1, ServiceObjectiveNamePRS2, ServiceObjectiveNamePRS4, ServiceObjectiveNamePRS6, ServiceObjectiveNameS0, ServiceObjectiveNameS1, ServiceObjectiveNameS12, ServiceObjectiveNameS2, ServiceObjectiveNameS3, ServiceObjectiveNameS4, ServiceObjectiveNameS6, ServiceObjectiveNameS7, ServiceObjectiveNameS9, ServiceObjectiveNameSystem, ServiceObjectiveNameSystem0, ServiceObjectiveNameSystem1, ServiceObjectiveNameSystem2, ServiceObjectiveNameSystem2L, ServiceObjectiveNameSystem3, ServiceObjectiveNameSystem3L, ServiceObjectiveNameSystem4, ServiceObjectiveNameSystem4L} +} + +// StorageKeyType enumerates the values for storage key type. +type StorageKeyType string + +const ( + // SharedAccessKey ... + SharedAccessKey StorageKeyType = "SharedAccessKey" + // StorageAccessKey ... + StorageAccessKey StorageKeyType = "StorageAccessKey" +) + +// PossibleStorageKeyTypeValues returns an array of possible values for the StorageKeyType const type. +func PossibleStorageKeyTypeValues() []StorageKeyType { + return []StorageKeyType{SharedAccessKey, StorageAccessKey} +} + +// SyncAgentState enumerates the values for sync agent state. +type SyncAgentState string + +const ( + // NeverConnected ... + NeverConnected SyncAgentState = "NeverConnected" + // Offline ... + Offline SyncAgentState = "Offline" + // Online ... + Online SyncAgentState = "Online" +) + +// PossibleSyncAgentStateValues returns an array of possible values for the SyncAgentState const type. +func PossibleSyncAgentStateValues() []SyncAgentState { + return []SyncAgentState{NeverConnected, Offline, Online} +} + +// SyncConflictResolutionPolicy enumerates the values for sync conflict resolution policy. +type SyncConflictResolutionPolicy string + +const ( + // HubWin ... + HubWin SyncConflictResolutionPolicy = "HubWin" + // MemberWin ... + MemberWin SyncConflictResolutionPolicy = "MemberWin" +) + +// PossibleSyncConflictResolutionPolicyValues returns an array of possible values for the SyncConflictResolutionPolicy const type. +func PossibleSyncConflictResolutionPolicyValues() []SyncConflictResolutionPolicy { + return []SyncConflictResolutionPolicy{HubWin, MemberWin} +} + +// SyncDirection enumerates the values for sync direction. +type SyncDirection string + +const ( + // Bidirectional ... + Bidirectional SyncDirection = "Bidirectional" + // OneWayHubToMember ... + OneWayHubToMember SyncDirection = "OneWayHubToMember" + // OneWayMemberToHub ... + OneWayMemberToHub SyncDirection = "OneWayMemberToHub" +) + +// PossibleSyncDirectionValues returns an array of possible values for the SyncDirection const type. +func PossibleSyncDirectionValues() []SyncDirection { + return []SyncDirection{Bidirectional, OneWayHubToMember, OneWayMemberToHub} +} + +// SyncGroupLogType enumerates the values for sync group log type. +type SyncGroupLogType string + +const ( + // SyncGroupLogTypeAll ... + SyncGroupLogTypeAll SyncGroupLogType = "All" + // SyncGroupLogTypeError ... + SyncGroupLogTypeError SyncGroupLogType = "Error" + // SyncGroupLogTypeSuccess ... + SyncGroupLogTypeSuccess SyncGroupLogType = "Success" + // SyncGroupLogTypeWarning ... + SyncGroupLogTypeWarning SyncGroupLogType = "Warning" +) + +// PossibleSyncGroupLogTypeValues returns an array of possible values for the SyncGroupLogType const type. +func PossibleSyncGroupLogTypeValues() []SyncGroupLogType { + return []SyncGroupLogType{SyncGroupLogTypeAll, SyncGroupLogTypeError, SyncGroupLogTypeSuccess, SyncGroupLogTypeWarning} +} + +// SyncGroupState enumerates the values for sync group state. +type SyncGroupState string + +const ( + // Error ... + Error SyncGroupState = "Error" + // Good ... + Good SyncGroupState = "Good" + // NotReady ... + NotReady SyncGroupState = "NotReady" + // Progressing ... + Progressing SyncGroupState = "Progressing" + // Warning ... + Warning SyncGroupState = "Warning" +) + +// PossibleSyncGroupStateValues returns an array of possible values for the SyncGroupState const type. +func PossibleSyncGroupStateValues() []SyncGroupState { + return []SyncGroupState{Error, Good, NotReady, Progressing, Warning} +} + +// SyncMemberDbType enumerates the values for sync member db type. +type SyncMemberDbType string + +const ( + // AzureSQLDatabase ... + AzureSQLDatabase SyncMemberDbType = "AzureSqlDatabase" + // SQLServerDatabase ... + SQLServerDatabase SyncMemberDbType = "SqlServerDatabase" +) + +// PossibleSyncMemberDbTypeValues returns an array of possible values for the SyncMemberDbType const type. +func PossibleSyncMemberDbTypeValues() []SyncMemberDbType { + return []SyncMemberDbType{AzureSQLDatabase, SQLServerDatabase} +} + +// SyncMemberState enumerates the values for sync member state. +type SyncMemberState string + +const ( + // DeProvisioned ... + DeProvisioned SyncMemberState = "DeProvisioned" + // DeProvisionFailed ... + DeProvisionFailed SyncMemberState = "DeProvisionFailed" + // DeProvisioning ... + DeProvisioning SyncMemberState = "DeProvisioning" + // DisabledBackupRestore ... + DisabledBackupRestore SyncMemberState = "DisabledBackupRestore" + // DisabledTombstoneCleanup ... + DisabledTombstoneCleanup SyncMemberState = "DisabledTombstoneCleanup" + // Provisioned ... + Provisioned SyncMemberState = "Provisioned" + // ProvisionFailed ... + ProvisionFailed SyncMemberState = "ProvisionFailed" + // Provisioning ... + Provisioning SyncMemberState = "Provisioning" + // ReprovisionFailed ... + ReprovisionFailed SyncMemberState = "ReprovisionFailed" + // Reprovisioning ... + Reprovisioning SyncMemberState = "Reprovisioning" + // SyncCancelled ... + SyncCancelled SyncMemberState = "SyncCancelled" + // SyncCancelling ... + SyncCancelling SyncMemberState = "SyncCancelling" + // SyncFailed ... + SyncFailed SyncMemberState = "SyncFailed" + // SyncInProgress ... + SyncInProgress SyncMemberState = "SyncInProgress" + // SyncSucceeded ... + SyncSucceeded SyncMemberState = "SyncSucceeded" + // SyncSucceededWithWarnings ... + SyncSucceededWithWarnings SyncMemberState = "SyncSucceededWithWarnings" + // UnProvisioned ... + UnProvisioned SyncMemberState = "UnProvisioned" + // UnReprovisioned ... + UnReprovisioned SyncMemberState = "UnReprovisioned" +) + +// PossibleSyncMemberStateValues returns an array of possible values for the SyncMemberState const type. +func PossibleSyncMemberStateValues() []SyncMemberState { + return []SyncMemberState{DeProvisioned, DeProvisionFailed, DeProvisioning, DisabledBackupRestore, DisabledTombstoneCleanup, Provisioned, ProvisionFailed, Provisioning, ReprovisionFailed, Reprovisioning, SyncCancelled, SyncCancelling, SyncFailed, SyncInProgress, SyncSucceeded, SyncSucceededWithWarnings, UnProvisioned, UnReprovisioned} +} + +// TransparentDataEncryptionActivityStatus enumerates the values for transparent data encryption activity +// status. +type TransparentDataEncryptionActivityStatus string + +const ( + // Decrypting ... + Decrypting TransparentDataEncryptionActivityStatus = "Decrypting" + // Encrypting ... + Encrypting TransparentDataEncryptionActivityStatus = "Encrypting" +) + +// PossibleTransparentDataEncryptionActivityStatusValues returns an array of possible values for the TransparentDataEncryptionActivityStatus const type. +func PossibleTransparentDataEncryptionActivityStatusValues() []TransparentDataEncryptionActivityStatus { + return []TransparentDataEncryptionActivityStatus{Decrypting, Encrypting} +} + +// TransparentDataEncryptionStatus enumerates the values for transparent data encryption status. +type TransparentDataEncryptionStatus string + +const ( + // TransparentDataEncryptionStatusDisabled ... + TransparentDataEncryptionStatusDisabled TransparentDataEncryptionStatus = "Disabled" + // TransparentDataEncryptionStatusEnabled ... + TransparentDataEncryptionStatusEnabled TransparentDataEncryptionStatus = "Enabled" +) + +// PossibleTransparentDataEncryptionStatusValues returns an array of possible values for the TransparentDataEncryptionStatus const type. +func PossibleTransparentDataEncryptionStatusValues() []TransparentDataEncryptionStatus { + return []TransparentDataEncryptionStatus{TransparentDataEncryptionStatusDisabled, TransparentDataEncryptionStatusEnabled} +} + +// UnitDefinitionType enumerates the values for unit definition type. +type UnitDefinitionType string + +const ( + // Bytes ... + Bytes UnitDefinitionType = "Bytes" + // BytesPerSecond ... + BytesPerSecond UnitDefinitionType = "BytesPerSecond" + // Count ... + Count UnitDefinitionType = "Count" + // CountPerSecond ... + CountPerSecond UnitDefinitionType = "CountPerSecond" + // Percent ... + Percent UnitDefinitionType = "Percent" + // Seconds ... + Seconds UnitDefinitionType = "Seconds" +) + +// PossibleUnitDefinitionTypeValues returns an array of possible values for the UnitDefinitionType const type. +func PossibleUnitDefinitionTypeValues() []UnitDefinitionType { + return []UnitDefinitionType{Bytes, BytesPerSecond, Count, CountPerSecond, Percent, Seconds} +} + +// UnitType enumerates the values for unit type. +type UnitType string + +const ( + // UnitTypeBytes ... + UnitTypeBytes UnitType = "bytes" + // UnitTypeBytesPerSecond ... + UnitTypeBytesPerSecond UnitType = "bytesPerSecond" + // UnitTypeCount ... + UnitTypeCount UnitType = "count" + // UnitTypeCountPerSecond ... + UnitTypeCountPerSecond UnitType = "countPerSecond" + // UnitTypePercent ... + UnitTypePercent UnitType = "percent" + // UnitTypeSeconds ... + UnitTypeSeconds UnitType = "seconds" +) + +// PossibleUnitTypeValues returns an array of possible values for the UnitType const type. +func PossibleUnitTypeValues() []UnitType { + return []UnitType{UnitTypeBytes, UnitTypeBytesPerSecond, UnitTypeCount, UnitTypeCountPerSecond, UnitTypePercent, UnitTypeSeconds} +} + +// VirtualNetworkRuleState enumerates the values for virtual network rule state. +type VirtualNetworkRuleState string + +const ( + // Deleting ... + Deleting VirtualNetworkRuleState = "Deleting" + // Initializing ... + Initializing VirtualNetworkRuleState = "Initializing" + // InProgress ... + InProgress VirtualNetworkRuleState = "InProgress" + // Ready ... + Ready VirtualNetworkRuleState = "Ready" + // Unknown ... + Unknown VirtualNetworkRuleState = "Unknown" +) + +// PossibleVirtualNetworkRuleStateValues returns an array of possible values for the VirtualNetworkRuleState const type. +func PossibleVirtualNetworkRuleStateValues() []VirtualNetworkRuleState { + return []VirtualNetworkRuleState{Deleting, Initializing, InProgress, Ready, Unknown} +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/failovergroups.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/failovergroups.go new file mode 100644 index 000000000000..bab986e12e9e --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/failovergroups.go @@ -0,0 +1,658 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FailoverGroupsClient 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 FailoverGroupsClient struct { + BaseClient +} + +// NewFailoverGroupsClient creates an instance of the FailoverGroupsClient client. +func NewFailoverGroupsClient(subscriptionID string) FailoverGroupsClient { + return NewFailoverGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFailoverGroupsClientWithBaseURI creates an instance of the FailoverGroupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) FailoverGroupsClient { + return FailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client FailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (result FailoverGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FailoverGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.FailoverGroupProperties.ReadWriteEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FailoverGroupProperties.PartnerServers", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.FailoverGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FailoverGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) CreateOrUpdateSender(req *http.Request) (future FailoverGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FailoverGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) DeleteSender(req *http.Request) (future FailoverGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary server to this server. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client FailoverGroupsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) FailoverSender(req *http.Request) (future FailoverGroupsFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) FailoverResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ForceFailoverAllowDataLoss fails over from the current primary server to this server. This operation might result in +// data loss. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ForceFailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ForceFailoverAllowDataLossPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.ForceFailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ForceFailoverAllowDataLoss", result.Response(), "Failure sending request") + return + } + + return +} + +// ForceFailoverAllowDataLossPreparer prepares the ForceFailoverAllowDataLoss request. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ForceFailoverAllowDataLossSender sends the ForceFailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossSender(req *http.Request) (future FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ForceFailoverAllowDataLossResponder handles the response to the ForceFailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "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.FailoverGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FailoverGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) GetResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the failover groups in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +func (client FailoverGroupsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ListByServer") + defer func() { + sc := -1 + if result.fglr.Response.Response != nil { + sc = result.fglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.fglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.fglr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.fglr.hasNextLink() && result.fglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FailoverGroupsClient) 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 = "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}/failoverGroups", 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 FailoverGroupsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ListByServerResponder(resp *http.Response) (result FailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + 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 FailoverGroupsClient) listByServerNextResults(ctx context.Context, lastResults FailoverGroupListResult) (result FailoverGroupListResult, err error) { + req, err := lastResults.failoverGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "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.FailoverGroupsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FailoverGroupsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client FailoverGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (result FailoverGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client FailoverGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) UpdateSender(req *http.Request) (future FailoverGroupsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) UpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/firewallrules.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/firewallrules.go new file mode 100644 index 000000000000..3e79a6b3933c --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/firewallrules.go @@ -0,0 +1,361 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FirewallRulesClient 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 FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "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.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "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.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of firewall rules. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) 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 = "2014-04-01" + 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}/firewallRules", 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 FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/geobackuppolicies.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/geobackuppolicies.go new file mode 100644 index 000000000000..605603cc5f04 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/geobackuppolicies.go @@ -0,0 +1,285 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GeoBackupPoliciesClient 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 GeoBackupPoliciesClient struct { + BaseClient +} + +// NewGeoBackupPoliciesClient creates an instance of the GeoBackupPoliciesClient client. +func NewGeoBackupPoliciesClient(subscriptionID string) GeoBackupPoliciesClient { + return NewGeoBackupPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGeoBackupPoliciesClientWithBaseURI creates an instance of the GeoBackupPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewGeoBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) GeoBackupPoliciesClient { + return GeoBackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database geo backup policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating the geo backup policy. +func (client GeoBackupPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters GeoBackupPolicy) (result GeoBackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.GeoBackupPolicyProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.GeoBackupPoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "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.GeoBackupPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GeoBackupPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters GeoBackupPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "geoBackupPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", 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 GeoBackupPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a geo backup policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client GeoBackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "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.GeoBackupPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GeoBackupPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "geoBackupPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/geoBackupPolicies/{geoBackupPolicyName}", 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 GeoBackupPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) GetResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a list of geo backup policies. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client GeoBackupPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicyListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client GeoBackupPoliciesClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/geoBackupPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GeoBackupPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result GeoBackupPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/managedinstances.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/managedinstances.go new file mode 100644 index 000000000000..58b525bf1774 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/managedinstances.go @@ -0,0 +1,594 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstancesClient 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 ManagedInstancesClient struct { + BaseClient +} + +// NewManagedInstancesClient creates an instance of the ManagedInstancesClient client. +func NewManagedInstancesClient(subscriptionID string) ManagedInstancesClient { + return NewManagedInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstancesClientWithBaseURI creates an instance of the ManagedInstancesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstancesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstancesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstancesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstancesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-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/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) DeleteSender(req *http.Request) (future ManagedInstancesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "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.ManagedInstancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstancesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all managed instances in the subscription. +func (client ManagedInstancesClient) List(ctx context.Context) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.List") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", resp, "Failure sending request") + return + } + + result.milr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ManagedInstancesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "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}/providers/Microsoft.Sql/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListComplete(ctx context.Context) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.milr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ManagedInstancesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByResourceGroupResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedInstancesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) UpdateSender(req *http.Request) (future ManagedInstancesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/models.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/models.go new file mode 100644 index 000000000000..581f17ac7fdc --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/models.go @@ -0,0 +1,10306 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql" + +// CheckNameAvailabilityRequest a request to check whether the specified name for a resource is available. +type CheckNameAvailabilityRequest struct { + // Name - The name whose availability is to be checked. + Name *string `json:"name,omitempty"` + // Type - The type of resource that is used as the scope of the availability check. + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResponse a response indicating whether the specified name for a resource is +// available. +type CheckNameAvailabilityResponse struct { + autorest.Response `json:"-"` + // Available - READ-ONLY; True if the name is available, otherwise false. + Available *bool `json:"available,omitempty"` + // Message - READ-ONLY; A message explaining why the name is unavailable. Will be null if the name is available. + Message *string `json:"message,omitempty"` + // Name - READ-ONLY; The name whose availability was checked. + Name *string `json:"name,omitempty"` + // Reason - READ-ONLY; The reason code explaining why the name is unavailable. Will be null if the name is available. Possible values include: 'Invalid', 'AlreadyExists' + Reason CheckNameAvailabilityReason `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for CheckNameAvailabilityResponse. +func (cnar CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Database represents a database. +type Database struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of database. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // DatabaseProperties - The properties representing the resource. + *DatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + d.Kind = &kind + } + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseBlobAuditingPolicy a database blob auditing policy. +type DatabaseBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseBlobAuditingPolicyProperties - Resource properties. + *DatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseBlobAuditingPolicy. +func (dbap DatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dbap.DatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = dbap.DatabaseBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseBlobAuditingPolicy struct. +func (dbap *DatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dbap.Kind = &kind + } + case "properties": + if v != nil { + var databaseBlobAuditingPolicyProperties DatabaseBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &databaseBlobAuditingPolicyProperties) + if err != nil { + return err + } + dbap.DatabaseBlobAuditingPolicyProperties = &databaseBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dbap.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseBlobAuditingPolicyListResult a list of database auditing settings. +type DatabaseBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseBlobAuditingPolicyListResult. +func (dbaplr DatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of +// DatabaseBlobAuditingPolicy values. +type DatabaseBlobAuditingPolicyListResultIterator struct { + i int + page DatabaseBlobAuditingPolicyListResultPage +} + +// NextWithContext 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 *DatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseBlobAuditingPolicyListResultIterator) 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 DatabaseBlobAuditingPolicyListResultIterator) Response() DatabaseBlobAuditingPolicyListResult { + 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 DatabaseBlobAuditingPolicyListResultIterator) Value() DatabaseBlobAuditingPolicy { + if !iter.page.NotDone() { + return DatabaseBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseBlobAuditingPolicyListResultIterator type. +func NewDatabaseBlobAuditingPolicyListResultIterator(page DatabaseBlobAuditingPolicyListResultPage) DatabaseBlobAuditingPolicyListResultIterator { + return DatabaseBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dbaplr DatabaseBlobAuditingPolicyListResult) IsEmpty() bool { + return dbaplr.Value == nil || len(*dbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dbaplr DatabaseBlobAuditingPolicyListResult) hasNextLink() bool { + return dbaplr.NextLink != nil && len(*dbaplr.NextLink) != 0 +} + +// databaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dbaplr DatabaseBlobAuditingPolicyListResult) databaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dbaplr.NextLink))) +} + +// DatabaseBlobAuditingPolicyListResultPage contains a page of DatabaseBlobAuditingPolicy values. +type DatabaseBlobAuditingPolicyListResultPage struct { + fn func(context.Context, DatabaseBlobAuditingPolicyListResult) (DatabaseBlobAuditingPolicyListResult, error) + dbaplr DatabaseBlobAuditingPolicyListResult +} + +// NextWithContext 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 *DatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dbaplr) + if err != nil { + return err + } + page.dbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.dbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseBlobAuditingPolicyListResultPage) Response() DatabaseBlobAuditingPolicyListResult { + return page.dbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseBlobAuditingPolicyListResultPage) Values() []DatabaseBlobAuditingPolicy { + if page.dbaplr.IsEmpty() { + return nil + } + return *page.dbaplr.Value +} + +// Creates a new instance of the DatabaseBlobAuditingPolicyListResultPage type. +func NewDatabaseBlobAuditingPolicyListResultPage(cur DatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, DatabaseBlobAuditingPolicyListResult) (DatabaseBlobAuditingPolicyListResult, error)) DatabaseBlobAuditingPolicyListResultPage { + return DatabaseBlobAuditingPolicyListResultPage{ + fn: getNextPage, + dbaplr: cur, + } +} + +// DatabaseBlobAuditingPolicyProperties properties of a database blob auditing policy. +type DatabaseBlobAuditingPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'Enabled', 'Disabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` +} + +// DatabaseListResult represents the response to a list database request. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - The list of databases housed in the server. + Value *[]Database `json:"value,omitempty"` +} + +// DatabaseProperties represents the properties of a database. +type DatabaseProperties struct { + // Collation - The collation of the database. If createMode is not Default, this value is ignored. + Collation *string `json:"collation,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // ContainmentState - READ-ONLY; The containment state of the database. + ContainmentState *int64 `json:"containmentState,omitempty"` + // CurrentServiceObjectiveID - READ-ONLY; The current service level objective ID of the database. This is the ID of the service level objective that is currently active. + CurrentServiceObjectiveID *uuid.UUID `json:"currentServiceObjectiveId,omitempty"` + // DatabaseID - READ-ONLY; The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // CreateMode - Specifies the mode of database creation. + // Default: regular database creation. + // Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database. + // OnlineSecondary/NonReadableSecondary: creates a database as a (readable or nonreadable) secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database. + // PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified. + // 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' + 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"` + // SourceDatabaseDeletionDate - Conditional. If createMode is Restore and sourceDatabaseId is the deleted database's original resource id when it existed (as opposed to its current restorable dropped database id), then this value is required. Specifies the time that the database was deleted. + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + // RestorePointInTime - Conditional. If createMode is PointInTimeRestore, this value is required. If createMode is Restore, this value is optional. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. Must be greater than or equal to the source database's earliestRestoreDate value. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // RecoveryServicesRecoveryPointResourceID - Conditional. If createMode is RestoreLongTermRetentionBackup, then this value is required. Specifies the resource ID of the recovery point to restore from. + RecoveryServicesRecoveryPointResourceID *string `json:"recoveryServicesRecoveryPointResourceId,omitempty"` + // Edition - The edition of the database. The DatabaseEditions enumeration contains all the valid editions. If createMode is NonReadableSecondary or OnlineSecondary, this value is ignored. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or one of the following commands: + // + // ```azurecli + // az sql db list-editions -l -o table + // ```` + // + // ```powershell + // Get-AzSqlServerServiceObjective -Location + // ```` + // . Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2', 'GeneralPurpose', 'BusinessCritical', 'Hyperscale' + Edition DatabaseEdition `json:"edition,omitempty"` + // MaxSizeBytes - The max size of the database expressed in bytes. If createMode is not Default, this value is ignored. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // RequestedServiceObjectiveID - The configured service level objective ID of the database. This is the service level objective that is in the process of being applied to the database. Once successfully updated, it will match the value of currentServiceObjectiveId property. If requestedServiceObjectiveId and requestedServiceObjectiveName are both updated, the value of requestedServiceObjectiveId overrides the value of requestedServiceObjectiveName. + // + // The list of SKUs may vary by region and support offer. To determine the service objective ids that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API. + RequestedServiceObjectiveID *uuid.UUID `json:"requestedServiceObjectiveId,omitempty"` + // RequestedServiceObjectiveName - The name of the configured service level objective of the database. This is the service level objective that is in the process of being applied to the database. Once successfully updated, it will match the value of serviceLevelObjective property. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or one of the following commands: + // + // ```azurecli + // az sql db list-editions -l -o table + // ```` + // + // ```powershell + // Get-AzSqlServerServiceObjective -Location + // ```` + // . 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' + RequestedServiceObjectiveName ServiceObjectiveName `json:"requestedServiceObjectiveName,omitempty"` + // ServiceLevelObjective - READ-ONLY; The current service level objective of 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' + ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` + // Status - READ-ONLY; The status of the database. + Status *string `json:"status,omitempty"` + // ElasticPoolName - The name of the elastic pool the database is in. If elasticPoolName and requestedServiceObjectiveName are both updated, the value of requestedServiceObjectiveName is ignored. Not supported for DataWarehouse edition. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // ServiceTierAdvisors - READ-ONLY; The list of service tier advisors for this database. Expanded property + ServiceTierAdvisors *[]ServiceTierAdvisor `json:"serviceTierAdvisors,omitempty"` + // TransparentDataEncryption - READ-ONLY; The transparent data encryption info for this database. + TransparentDataEncryption *[]TransparentDataEncryption `json:"transparentDataEncryption,omitempty"` + // RecommendedIndex - READ-ONLY; The recommended indices for this database. + RecommendedIndex *[]RecommendedIndex `json:"recommendedIndex,omitempty"` + // FailoverGroupID - READ-ONLY; The resource identifier of the failover group containing this database. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // ReadScale - Conditional. If the database is a geo-secondary, readScale indicates whether read-only connections are allowed to this database or not. Not supported for DataWarehouse edition. Possible values include: 'ReadScaleEnabled', 'ReadScaleDisabled' + ReadScale ReadScale `json:"readScale,omitempty"` + // SampleName - Indicates the name of the sample schema to apply when creating this database. If createMode is not Default, this value is ignored. Not supported for DataWarehouse edition. Possible values include: 'AdventureWorksLT' + SampleName SampleName `json:"sampleName,omitempty"` + // ZoneRedundant - Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseProperties. +func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.Collation != nil { + objectMap["collation"] = dp.Collation + } + if dp.CreateMode != "" { + objectMap["createMode"] = dp.CreateMode + } + if dp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = dp.SourceDatabaseID + } + if dp.SourceDatabaseDeletionDate != nil { + objectMap["sourceDatabaseDeletionDate"] = dp.SourceDatabaseDeletionDate + } + if dp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = dp.RestorePointInTime + } + if dp.RecoveryServicesRecoveryPointResourceID != nil { + objectMap["recoveryServicesRecoveryPointResourceId"] = dp.RecoveryServicesRecoveryPointResourceID + } + if dp.Edition != "" { + objectMap["edition"] = dp.Edition + } + if dp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = dp.MaxSizeBytes + } + if dp.RequestedServiceObjectiveID != nil { + objectMap["requestedServiceObjectiveId"] = dp.RequestedServiceObjectiveID + } + if dp.RequestedServiceObjectiveName != "" { + objectMap["requestedServiceObjectiveName"] = dp.RequestedServiceObjectiveName + } + if dp.ElasticPoolName != nil { + objectMap["elasticPoolName"] = dp.ElasticPoolName + } + if dp.ReadScale != "" { + objectMap["readScale"] = dp.ReadScale + } + if dp.SampleName != "" { + objectMap["sampleName"] = dp.SampleName + } + if dp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = dp.ZoneRedundant + } + return json.Marshal(objectMap) +} + +// DatabasesCreateImportOperationFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabasesCreateImportOperationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (ImportExportResponse, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateImportOperationFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesCreateImportOperationFuture.Result. +func (future *DatabasesCreateImportOperationFuture) result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ier.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesCreateImportOperationFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ier.Response.Response, err = future.GetResult(sender); err == nil && ier.Response.Response.StatusCode != http.StatusNoContent { + ier, err = client.CreateImportOperationResponder(ier.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", ier.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesCreateOrUpdateFuture.Result. +func (future *DatabasesCreateOrUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabaseSecurityAlertPolicy contains information about a database Threat Detection policy. +type DatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseSecurityAlertPolicyProperties - Properties of the security alert policy. + *DatabaseSecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseSecurityAlertPolicy. +func (dsap DatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsap.Location != nil { + objectMap["location"] = dsap.Location + } + if dsap.DatabaseSecurityAlertPolicyProperties != nil { + objectMap["properties"] = dsap.DatabaseSecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseSecurityAlertPolicy struct. +func (dsap *DatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dsap.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dsap.Kind = &kind + } + case "properties": + if v != nil { + var databaseSecurityAlertPolicyProperties DatabaseSecurityAlertPolicyProperties + err = json.Unmarshal(*v, &databaseSecurityAlertPolicyProperties) + if err != nil { + return err + } + dsap.DatabaseSecurityAlertPolicyProperties = &databaseSecurityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dsap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dsap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dsap.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseSecurityAlertPolicyProperties properties for a database Threat Detection policy. +type DatabaseSecurityAlertPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint and storageAccountAccessKey are required. Possible values include: 'SecurityAlertPolicyStateNew', 'SecurityAlertPolicyStateEnabled', 'SecurityAlertPolicyStateDisabled' + State SecurityAlertPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies the semicolon-separated list of alerts that are disabled, or empty string to disable no alerts. Possible values: Sql_Injection; Sql_Injection_Vulnerability; Access_Anomaly; Data_Exfiltration; Unsafe_Action. + DisabledAlerts *string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies the semicolon-separated list of e-mail addresses to which the alert is sent. + EmailAddresses *string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. Possible values include: 'SecurityAlertPolicyEmailAccountAdminsEnabled', 'SecurityAlertPolicyEmailAccountAdminsDisabled' + EmailAccountAdmins SecurityAlertPolicyEmailAccountAdmins `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. If state is Enabled, storageEndpoint is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. If state is Enabled, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // UseServerDefault - Specifies whether to use the default server policy. Possible values include: 'SecurityAlertPolicyUseServerDefaultEnabled', 'SecurityAlertPolicyUseServerDefaultDisabled' + UseServerDefault SecurityAlertPolicyUseServerDefault `json:"useServerDefault,omitempty"` +} + +// DatabasesExportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesExportFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (ImportExportResponse, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesExportFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesExportFuture.Result. +func (future *DatabasesExportFuture) result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ier.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ier.Response.Response, err = future.GetResult(sender); err == nil && ier.Response.Response.StatusCode != http.StatusNoContent { + ier, err = client.ExportResponder(ier.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", ier.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesImportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesImportFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (ImportExportResponse, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesImportFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesImportFuture.Result. +func (future *DatabasesImportFuture) result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ier.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ier.Response.Response, err = future.GetResult(sender); err == nil && ier.Response.Response.StatusCode != http.StatusNoContent { + ier, err = client.ImportResponder(ier.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", ier.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesPauseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesPauseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesPauseFuture.Result. +func (future *DatabasesPauseFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesResumeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesResumeFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesResumeFuture.Result. +func (future *DatabasesResumeFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpdateFuture.Result. +func (future *DatabasesUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabaseUpdate represents a database update. +type DatabaseUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // DatabaseProperties - The properties representing the resource. + *DatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUpdate. +func (du DatabaseUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if du.Tags != nil { + objectMap["tags"] = du.Tags + } + if du.DatabaseProperties != nil { + objectMap["properties"] = du.DatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseUpdate struct. +func (du *DatabaseUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + du.Tags = tags + } + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + du.DatabaseProperties = &databaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + du.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + du.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + du.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseUsage the database usages. +type DatabaseUsage struct { + // Name - READ-ONLY; The name of the usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - READ-ONLY; The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - READ-ONLY; The usage metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; The current value of the usage metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; The current limit of the usage metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units of the usage metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - READ-ONLY; The next reset time for the usage metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUsage. +func (du DatabaseUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseUsageListResult the response to a list database metrics request. +type DatabaseUsageListResult struct { + autorest.Response `json:"-"` + // Value - The list of database usages for the database. + Value *[]DatabaseUsage `json:"value,omitempty"` +} + +// DataMaskingPolicy represents a database data masking policy. +type DataMaskingPolicy struct { + autorest.Response `json:"-"` + // DataMaskingPolicyProperties - The properties of the data masking policy. + *DataMaskingPolicyProperties `json:"properties,omitempty"` + // Location - READ-ONLY; The location of the data masking policy. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; The kind of data masking policy. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingPolicy. +func (dmp DataMaskingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmp.DataMaskingPolicyProperties != nil { + objectMap["properties"] = dmp.DataMaskingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataMaskingPolicy struct. +func (dmp *DataMaskingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataMaskingPolicyProperties DataMaskingPolicyProperties + err = json.Unmarshal(*v, &dataMaskingPolicyProperties) + if err != nil { + return err + } + dmp.DataMaskingPolicyProperties = &dataMaskingPolicyProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dmp.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dmp.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dmp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dmp.Type = &typeVar + } + } + } + + return nil +} + +// DataMaskingPolicyProperties the properties of a database data masking policy. +type DataMaskingPolicyProperties struct { + // DataMaskingState - The state of the data masking policy. Possible values include: 'DataMaskingStateDisabled', 'DataMaskingStateEnabled' + DataMaskingState DataMaskingState `json:"dataMaskingState,omitempty"` + // ExemptPrincipals - The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users receive data results without masking for all of the database queries. + ExemptPrincipals *string `json:"exemptPrincipals,omitempty"` + // ApplicationPrincipals - READ-ONLY; The list of the application principals. This is a legacy parameter and is no longer used. + ApplicationPrincipals *string `json:"applicationPrincipals,omitempty"` + // MaskingLevel - READ-ONLY; The masking level. This is a legacy parameter and is no longer used. + MaskingLevel *string `json:"maskingLevel,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingPolicyProperties. +func (dmpp DataMaskingPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmpp.DataMaskingState != "" { + objectMap["dataMaskingState"] = dmpp.DataMaskingState + } + if dmpp.ExemptPrincipals != nil { + objectMap["exemptPrincipals"] = dmpp.ExemptPrincipals + } + return json.Marshal(objectMap) +} + +// DataMaskingRule represents a database data masking rule. +type DataMaskingRule struct { + autorest.Response `json:"-"` + // DataMaskingRuleProperties - The properties of the resource. + *DataMaskingRuleProperties `json:"properties,omitempty"` + // Location - READ-ONLY; The location of the data masking rule. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; The kind of Data Masking Rule. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingRule. +func (dmr DataMaskingRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmr.DataMaskingRuleProperties != nil { + objectMap["properties"] = dmr.DataMaskingRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataMaskingRule struct. +func (dmr *DataMaskingRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataMaskingRuleProperties DataMaskingRuleProperties + err = json.Unmarshal(*v, &dataMaskingRuleProperties) + if err != nil { + return err + } + dmr.DataMaskingRuleProperties = &dataMaskingRuleProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dmr.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dmr.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dmr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dmr.Type = &typeVar + } + } + } + + return nil +} + +// DataMaskingRuleListResult the response to a list data masking rules request. +type DataMaskingRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of database data masking rules. + Value *[]DataMaskingRule `json:"value,omitempty"` +} + +// DataMaskingRuleProperties the properties of a database data masking rule. +type DataMaskingRuleProperties struct { + // ID - READ-ONLY; The rule Id. + ID *string `json:"id,omitempty"` + // AliasName - The alias name. This is a legacy parameter and is no longer used. + AliasName *string `json:"aliasName,omitempty"` + // RuleState - The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState. Possible values include: 'DataMaskingRuleStateDisabled', 'DataMaskingRuleStateEnabled' + RuleState DataMaskingRuleState `json:"ruleState,omitempty"` + // SchemaName - The schema name on which the data masking rule is applied. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - The table name on which the data masking rule is applied. + TableName *string `json:"tableName,omitempty"` + // ColumnName - The column name on which the data masking rule is applied. + ColumnName *string `json:"columnName,omitempty"` + // MaskingFunction - The masking function that is used for the data masking rule. Possible values include: 'DataMaskingFunctionDefault', 'DataMaskingFunctionCCN', 'DataMaskingFunctionEmail', 'DataMaskingFunctionNumber', 'DataMaskingFunctionSSN', 'DataMaskingFunctionText' + MaskingFunction DataMaskingFunction `json:"maskingFunction,omitempty"` + // NumberFrom - The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. + NumberFrom *string `json:"numberFrom,omitempty"` + // NumberTo - The numberTo property of the data masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. + NumberTo *string `json:"numberTo,omitempty"` + // PrefixSize - If maskingFunction is set to Text, the number of characters to show unmasked in the beginning of the string. Otherwise, this parameter will be ignored. + PrefixSize *string `json:"prefixSize,omitempty"` + // SuffixSize - If maskingFunction is set to Text, the number of characters to show unmasked at the end of the string. Otherwise, this parameter will be ignored. + SuffixSize *string `json:"suffixSize,omitempty"` + // ReplacementString - If maskingFunction is set to Text, the character to use for masking the unexposed part of the string. Otherwise, this parameter will be ignored. + ReplacementString *string `json:"replacementString,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingRuleProperties. +func (dmrp DataMaskingRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmrp.AliasName != nil { + objectMap["aliasName"] = dmrp.AliasName + } + if dmrp.RuleState != "" { + objectMap["ruleState"] = dmrp.RuleState + } + if dmrp.SchemaName != nil { + objectMap["schemaName"] = dmrp.SchemaName + } + if dmrp.TableName != nil { + objectMap["tableName"] = dmrp.TableName + } + if dmrp.ColumnName != nil { + objectMap["columnName"] = dmrp.ColumnName + } + if dmrp.MaskingFunction != "" { + objectMap["maskingFunction"] = dmrp.MaskingFunction + } + if dmrp.NumberFrom != nil { + objectMap["numberFrom"] = dmrp.NumberFrom + } + if dmrp.NumberTo != nil { + objectMap["numberTo"] = dmrp.NumberTo + } + if dmrp.PrefixSize != nil { + objectMap["prefixSize"] = dmrp.PrefixSize + } + if dmrp.SuffixSize != nil { + objectMap["suffixSize"] = dmrp.SuffixSize + } + if dmrp.ReplacementString != nil { + objectMap["replacementString"] = dmrp.ReplacementString + } + return json.Marshal(objectMap) +} + +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - READ-ONLY; The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - READ-ONLY; The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceLevelObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for EditionCapability. +func (ec EditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.Reason != nil { + objectMap["reason"] = ec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPool represents a database elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // ElasticPoolProperties - The properties representing the resource. + *ElasticPoolProperties `json:"properties,omitempty"` + // Kind - READ-ONLY; Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPool. +func (ep ElasticPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.ElasticPoolProperties != nil { + objectMap["properties"] = ep.ElasticPoolProperties + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPool struct. +func (ep *ElasticPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var elasticPoolProperties ElasticPoolProperties + err = json.Unmarshal(*v, &elasticPoolProperties) + if err != nil { + return err + } + ep.ElasticPoolProperties = &elasticPoolProperties + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolActivity represents the activity on an elastic pool. +type ElasticPoolActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolActivityProperties - The properties representing the resource. + *ElasticPoolActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolActivity. +func (epa ElasticPoolActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epa.Location != nil { + objectMap["location"] = epa.Location + } + if epa.ElasticPoolActivityProperties != nil { + objectMap["properties"] = epa.ElasticPoolActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolActivity struct. +func (epa *ElasticPoolActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epa.Location = &location + } + case "properties": + if v != nil { + var elasticPoolActivityProperties ElasticPoolActivityProperties + err = json.Unmarshal(*v, &elasticPoolActivityProperties) + if err != nil { + return err + } + epa.ElasticPoolActivityProperties = &elasticPoolActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epa.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolActivityListResult represents the response to a list elastic pool activity request. +type ElasticPoolActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool activities. + Value *[]ElasticPoolActivity `json:"value,omitempty"` +} + +// ElasticPoolActivityProperties represents the properties of an elastic pool. +type ElasticPoolActivityProperties struct { + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedDatabaseDtuMax - READ-ONLY; The requested max DTU per database if available. + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + // RequestedDatabaseDtuMin - READ-ONLY; The requested min DTU per database if available. + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + // RequestedDtu - READ-ONLY; The requested DTU for the pool if available. + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The requested name for the elastic pool if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // RequestedStorageLimitInGB - READ-ONLY; The requested storage limit for the pool in GB if available. + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + // ElasticPoolName - READ-ONLY; The name of the elastic pool. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` + // RequestedStorageLimitInMB - READ-ONLY; The requested storage limit in MB. + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + // RequestedDatabaseDtuGuarantee - READ-ONLY; The requested per database DTU guarantee. + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + // RequestedDatabaseDtuCap - READ-ONLY; The requested per database DTU cap. + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + // RequestedDtuGuarantee - READ-ONLY; The requested DTU guarantee. + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolActivityProperties. +func (epap ElasticPoolActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolDatabaseActivity represents the activity on an elastic pool. +type ElasticPoolDatabaseActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolDatabaseActivityProperties - The properties representing the resource. + *ElasticPoolDatabaseActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivity. +func (epda ElasticPoolDatabaseActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epda.Location != nil { + objectMap["location"] = epda.Location + } + if epda.ElasticPoolDatabaseActivityProperties != nil { + objectMap["properties"] = epda.ElasticPoolDatabaseActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolDatabaseActivity struct. +func (epda *ElasticPoolDatabaseActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epda.Location = &location + } + case "properties": + if v != nil { + var elasticPoolDatabaseActivityProperties ElasticPoolDatabaseActivityProperties + err = json.Unmarshal(*v, &elasticPoolDatabaseActivityProperties) + if err != nil { + return err + } + epda.ElasticPoolDatabaseActivityProperties = &elasticPoolDatabaseActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epda.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epda.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epda.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolDatabaseActivityListResult represents the response to a list elastic pool database activity +// request. +type ElasticPoolDatabaseActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool database activities. + Value *[]ElasticPoolDatabaseActivity `json:"value,omitempty"` +} + +// ElasticPoolDatabaseActivityProperties represents the properties of an elastic pool database activity. +type ElasticPoolDatabaseActivityProperties struct { + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The name for the elastic pool the database is moving into if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // CurrentElasticPoolName - READ-ONLY; The name of the current elastic pool the database is in if available. + CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` + // CurrentServiceObjective - READ-ONLY; The name of the current service objective if available. + CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` + // RequestedServiceObjective - READ-ONLY; The name of the requested service objective if available. + RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivityProperties. +func (epdap ElasticPoolDatabaseActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolDtuCapability the Elastic Pool DTU capability. +type ElasticPoolDtuCapability struct { + // Limit - READ-ONLY; The DTU limit for the pool. + Limit *int32 `json:"limit,omitempty"` + // MaxDatabaseCount - READ-ONLY; The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size for this DTU. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - READ-ONLY; The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxDtus - READ-ONLY; The list of supported per database max DTUs. + SupportedPerDatabaseMaxDtus *[]ElasticPoolPerDatabaseMaxDtuCapability `json:"supportedPerDatabaseMaxDtus,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDtuCapability. +func (epdc ElasticPoolDtuCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epdc.Reason != nil { + objectMap["reason"] = epdc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolEditionCapability the elastic pool edition capability. +type ElasticPoolEditionCapability struct { + // Name - READ-ONLY; The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolDtus - READ-ONLY; The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolDtus *[]ElasticPoolDtuCapability `json:"supportedElasticPoolDtus,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolEditionCapability. +func (epec ElasticPoolEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epec.Reason != nil { + objectMap["reason"] = epec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolListResult represents the response to a list elastic pool request. +type ElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pools hosted in the server. + Value *[]ElasticPool `json:"value,omitempty"` +} + +// ElasticPoolPerDatabaseMaxDtuCapability the max per-database DTU capability. +type ElasticPoolPerDatabaseMaxDtuCapability struct { + // Limit - READ-ONLY; The maximum DTUs per database. + Limit *int32 `json:"limit,omitempty"` + // SupportedPerDatabaseMinDtus - READ-ONLY; The list of supported min database DTUs. + SupportedPerDatabaseMinDtus *[]ElasticPoolPerDatabaseMinDtuCapability `json:"supportedPerDatabaseMinDtus,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMaxDtuCapability. +func (eppdmdc ElasticPoolPerDatabaseMaxDtuCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmdc.Reason != nil { + objectMap["reason"] = eppdmdc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMinDtuCapability the minimum per-database DTU capability. +type ElasticPoolPerDatabaseMinDtuCapability struct { + // Limit - READ-ONLY; The minimum DTUs per database. + Limit *int32 `json:"limit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMinDtuCapability. +func (eppdmdc ElasticPoolPerDatabaseMinDtuCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmdc.Reason != nil { + objectMap["reason"] = eppdmdc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolProperties represents the properties of an elastic pool. +type ElasticPoolProperties struct { + // CreationDate - READ-ONLY; The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // State - READ-ONLY; The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' + State ElasticPoolState `json:"state,omitempty"` + // Edition - The edition of the elastic pool. Possible values include: 'ElasticPoolEditionBasic', 'ElasticPoolEditionStandard', 'ElasticPoolEditionPremium', 'ElasticPoolEditionGeneralPurpose', 'ElasticPoolEditionBusinessCritical' + Edition ElasticPoolEdition `json:"edition,omitempty"` + // Dtu - The total shared DTU for the database elastic pool. + Dtu *int32 `json:"dtu,omitempty"` + // DatabaseDtuMax - The maximum DTU any one database can consume. + DatabaseDtuMax *int32 `json:"databaseDtuMax,omitempty"` + // DatabaseDtuMin - The minimum DTU all databases are guaranteed. + DatabaseDtuMin *int32 `json:"databaseDtuMin,omitempty"` + // StorageMB - Gets storage limit for the database elastic pool in MB. + StorageMB *int32 `json:"storageMB,omitempty"` + // ZoneRedundant - Whether or not this database elastic pool is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolProperties. +func (epp ElasticPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.Edition != "" { + objectMap["edition"] = epp.Edition + } + if epp.Dtu != nil { + objectMap["dtu"] = epp.Dtu + } + if epp.DatabaseDtuMax != nil { + objectMap["databaseDtuMax"] = epp.DatabaseDtuMax + } + if epp.DatabaseDtuMin != nil { + objectMap["databaseDtuMin"] = epp.DatabaseDtuMin + } + if epp.StorageMB != nil { + objectMap["storageMB"] = epp.StorageMB + } + if epp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = epp.ZoneRedundant + } + return json.Marshal(objectMap) +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsCreateOrUpdateFuture.Result. +func (future *ElasticPoolsCreateOrUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsUpdateFuture.Result. +func (future *ElasticPoolsUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.UpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolUpdate represents an elastic pool update. +type ElasticPoolUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ElasticPoolProperties - The properties representing the resource. + *ElasticPoolProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolUpdate. +func (epu ElasticPoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epu.Tags != nil { + objectMap["tags"] = epu.Tags + } + if epu.ElasticPoolProperties != nil { + objectMap["properties"] = epu.ElasticPoolProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolUpdate struct. +func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + epu.Tags = tags + } + case "properties": + if v != nil { + var elasticPoolProperties ElasticPoolProperties + err = json.Unmarshal(*v, &elasticPoolProperties) + if err != nil { + return err + } + epu.ElasticPoolProperties = &elasticPoolProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epu.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epu.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epu.Type = &typeVar + } + } + } + + return nil +} + +// EncryptionProtector the server encryption protector. +type EncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // EncryptionProtectorProperties - Resource properties. + *EncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtector. +func (ep EncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.EncryptionProtectorProperties != nil { + objectMap["properties"] = ep.EncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EncryptionProtector struct. +func (ep *EncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "properties": + if v != nil { + var encryptionProtectorProperties EncryptionProtectorProperties + err = json.Unmarshal(*v, &encryptionProtectorProperties) + if err != nil { + return err + } + ep.EncryptionProtectorProperties = &encryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// EncryptionProtectorListResult a list of server encryption protectors. +type EncryptionProtectorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]EncryptionProtector `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtectorListResult. +func (eplr EncryptionProtectorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector +// values. +type EncryptionProtectorListResultIterator struct { + i int + page EncryptionProtectorListResultPage +} + +// NextWithContext 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 *EncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EncryptionProtectorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EncryptionProtectorListResultIterator) 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 EncryptionProtectorListResultIterator) Response() EncryptionProtectorListResult { + 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 EncryptionProtectorListResultIterator) Value() EncryptionProtector { + if !iter.page.NotDone() { + return EncryptionProtector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EncryptionProtectorListResultIterator type. +func NewEncryptionProtectorListResultIterator(page EncryptionProtectorListResultPage) EncryptionProtectorListResultIterator { + return EncryptionProtectorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr EncryptionProtectorListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eplr EncryptionProtectorListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +} + +// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. +type EncryptionProtectorListResultPage struct { + fn func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error) + eplr EncryptionProtectorListResult +} + +// NextWithContext 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 *EncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eplr) + if err != nil { + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *EncryptionProtectorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EncryptionProtectorListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EncryptionProtectorListResultPage) Response() EncryptionProtectorListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EncryptionProtectorListResultPage) Values() []EncryptionProtector { + if page.eplr.IsEmpty() { + return nil + } + return *page.eplr.Value +} + +// Creates a new instance of the EncryptionProtectorListResultPage type. +func NewEncryptionProtectorListResultPage(cur EncryptionProtectorListResult, getNextPage func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error)) EncryptionProtectorListResultPage { + return EncryptionProtectorListResultPage{ + fn: getNextPage, + eplr: cur, + } +} + +// EncryptionProtectorProperties properties for an encryption protector execution. +type EncryptionProtectorProperties struct { + // Subregion - READ-ONLY; Subregion of the encryption protector. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyName - The name of the server key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtectorProperties. +func (epp EncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.ServerKeyName != nil { + objectMap["serverKeyName"] = epp.ServerKeyName + } + if epp.ServerKeyType != "" { + objectMap["serverKeyType"] = epp.ServerKeyType + } + return json.Marshal(objectMap) +} + +// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (EncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *EncryptionProtectorsCreateOrUpdateFuture) result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// EncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsRevalidateFuture.Result. +func (future *EncryptionProtectorsRevalidateFuture) result(client EncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ExportRequest export database parameters. +type ExportRequest 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"` +} + +// FailoverGroup a failover group. +type FailoverGroup struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // FailoverGroupProperties - Resource properties. + *FailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroup. +func (fg FailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fg.Tags != nil { + objectMap["tags"] = fg.Tags + } + if fg.FailoverGroupProperties != nil { + objectMap["properties"] = fg.FailoverGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroup struct. +func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fg.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fg.Tags = tags + } + case "properties": + if v != nil { + var failoverGroupProperties FailoverGroupProperties + err = json.Unmarshal(*v, &failoverGroupProperties) + if err != nil { + return err + } + fg.FailoverGroupProperties = &failoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fg.Type = &typeVar + } + } + } + + return nil +} + +// FailoverGroupListResult a list of failover groups. +type FailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]FailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupListResult. +func (fglr FailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. +type FailoverGroupListResultIterator struct { + i int + page FailoverGroupListResultPage +} + +// NextWithContext 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 *FailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *FailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FailoverGroupListResultIterator) 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 FailoverGroupListResultIterator) Response() FailoverGroupListResult { + 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 FailoverGroupListResultIterator) Value() FailoverGroup { + if !iter.page.NotDone() { + return FailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FailoverGroupListResultIterator type. +func NewFailoverGroupListResultIterator(page FailoverGroupListResultPage) FailoverGroupListResultIterator { + return FailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (fglr FailoverGroupListResult) IsEmpty() bool { + return fglr.Value == nil || len(*fglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (fglr FailoverGroupListResult) hasNextLink() bool { + return fglr.NextLink != nil && len(*fglr.NextLink) != 0 +} + +// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (fglr FailoverGroupListResult) failoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !fglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(fglr.NextLink))) +} + +// FailoverGroupListResultPage contains a page of FailoverGroup values. +type FailoverGroupListResultPage struct { + fn func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error) + fglr FailoverGroupListResult +} + +// NextWithContext 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 *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.fglr) + if err != nil { + return err + } + page.fglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *FailoverGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FailoverGroupListResultPage) NotDone() bool { + return !page.fglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FailoverGroupListResultPage) Response() FailoverGroupListResult { + return page.fglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FailoverGroupListResultPage) Values() []FailoverGroup { + if page.fglr.IsEmpty() { + return nil + } + return *page.fglr.Value +} + +// Creates a new instance of the FailoverGroupListResultPage type. +func NewFailoverGroupListResultPage(cur FailoverGroupListResult, getNextPage func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error)) FailoverGroupListResultPage { + return FailoverGroupListResultPage{ + fn: getNextPage, + fglr: cur, + } +} + +// FailoverGroupProperties properties of a failover group. +type FailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerServers - List of partner server information for the failover group. + PartnerServers *[]PartnerInfo `json:"partnerServers,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupProperties. +func (fgp FailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = fgp.ReadWriteEndpoint + } + if fgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = fgp.ReadOnlyEndpoint + } + if fgp.PartnerServers != nil { + objectMap["partnerServers"] = fgp.PartnerServers + } + if fgp.Databases != nil { + objectMap["databases"] = fgp.Databases + } + return json.Marshal(objectMap) +} + +// FailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type FailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// FailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type FailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'Manual', 'Automatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// FailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsCreateOrUpdateFuture.Result. +func (future *FailoverGroupsCreateOrUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.CreateOrUpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsDeleteFuture.Result. +func (future *FailoverGroupsDeleteFuture) result(client FailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsFailoverFuture.Result. +func (future *FailoverGroupsFailoverFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.FailoverResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type FailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.ForceFailoverAllowDataLossResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsUpdateFuture.Result. +func (future *FailoverGroupsUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.UpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupUpdate a failover group update request. +type FailoverGroupUpdate struct { + // FailoverGroupUpdateProperties - Resource properties. + *FailoverGroupUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupUpdate. +func (fgu FailoverGroupUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgu.FailoverGroupUpdateProperties != nil { + objectMap["properties"] = fgu.FailoverGroupUpdateProperties + } + if fgu.Tags != nil { + objectMap["tags"] = fgu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroupUpdate struct. +func (fgu *FailoverGroupUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var failoverGroupUpdateProperties FailoverGroupUpdateProperties + err = json.Unmarshal(*v, &failoverGroupUpdateProperties) + if err != nil { + return err + } + fgu.FailoverGroupUpdateProperties = &failoverGroupUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fgu.Tags = tags + } + } + } + + return nil +} + +// FailoverGroupUpdateProperties properties of a failover group update. +type FailoverGroupUpdateProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// FirewallRule represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of server that contains this firewall rule. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Location of the server that contains this firewall rule. + Location *string `json:"location,omitempty"` + // FirewallRuleProperties - The properties representing the resource. + *FirewallRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + fr.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fr.Location = &location + } + case "properties": + if v != nil { + var firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fr.Type = &typeVar + } + } + } + + return nil +} + +// FirewallRuleListResult represents the response to a List Firewall Rules request. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of server firewall rules. + Value *[]FirewallRule `json:"value,omitempty"` +} + +// FirewallRuleProperties represents the properties of a server firewall rule. +type FirewallRuleProperties struct { + // StartIPAddress - The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' to represent all Azure-internal IP addresses. + StartIPAddress *string `json:"startIpAddress,omitempty"` + // EndIPAddress - The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. Use value '0.0.0.0' to represent all Azure-internal IP addresses. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// GeoBackupPolicy a database geo backup policy. +type GeoBackupPolicy struct { + autorest.Response `json:"-"` + // GeoBackupPolicyProperties - The properties of the geo backup policy. + *GeoBackupPolicyProperties `json:"properties,omitempty"` + // Kind - READ-ONLY; Kind of geo backup policy. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Backup policy location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GeoBackupPolicy. +func (gbp GeoBackupPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbp.GeoBackupPolicyProperties != nil { + objectMap["properties"] = gbp.GeoBackupPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GeoBackupPolicy struct. +func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var geoBackupPolicyProperties GeoBackupPolicyProperties + err = json.Unmarshal(*v, &geoBackupPolicyProperties) + if err != nil { + return err + } + gbp.GeoBackupPolicyProperties = &geoBackupPolicyProperties + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + gbp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gbp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gbp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gbp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gbp.Type = &typeVar + } + } + } + + return nil +} + +// GeoBackupPolicyListResult the response to a list geo backup policies request. +type GeoBackupPolicyListResult struct { + autorest.Response `json:"-"` + // Value - The list of geo backup policies. + Value *[]GeoBackupPolicy `json:"value,omitempty"` +} + +// GeoBackupPolicyProperties the properties of the geo backup policy. +type GeoBackupPolicyProperties struct { + // State - The state of the geo backup policy. Possible values include: 'GeoBackupPolicyStateDisabled', 'GeoBackupPolicyStateEnabled' + State GeoBackupPolicyState `json:"state,omitempty"` + // StorageType - READ-ONLY; The storage type of the geo backup policy. + StorageType *string `json:"storageType,omitempty"` +} + +// MarshalJSON is the custom marshaler for GeoBackupPolicyProperties. +func (gbpp GeoBackupPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbpp.State != "" { + objectMap["state"] = gbpp.State + } + return json.Marshal(objectMap) +} + +// ImportExportResponse response for Import/Export Get operation. +type ImportExportResponse struct { + autorest.Response `json:"-"` + // ImportExportResponseProperties - The import/export operation properties. + *ImportExportResponseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportResponse. +func (ier ImportExportResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ier.ImportExportResponseProperties != nil { + objectMap["properties"] = ier.ImportExportResponseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ImportExportResponse struct. +func (ier *ImportExportResponse) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var importExportResponseProperties ImportExportResponseProperties + err = json.Unmarshal(*v, &importExportResponseProperties) + if err != nil { + return err + } + ier.ImportExportResponseProperties = &importExportResponseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ier.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ier.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ier.Type = &typeVar + } + } + } + + return nil +} + +// ImportExportResponseProperties response for Import/Export Status operation. +type ImportExportResponseProperties struct { + // RequestType - READ-ONLY; The request type of the operation. + RequestType *string `json:"requestType,omitempty"` + // RequestID - READ-ONLY; The request type of the operation. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; The name of the database. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - READ-ONLY; The status message returned from the server. + Status *string `json:"status,omitempty"` + // LastModifiedTime - READ-ONLY; The operation status last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // QueuedTime - READ-ONLY; The operation queued time. + QueuedTime *string `json:"queuedTime,omitempty"` + // BlobURI - READ-ONLY; The blob uri. + BlobURI *string `json:"blobUri,omitempty"` + // ErrorMessage - READ-ONLY; The error message returned from the server. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportResponseProperties. +func (ierp ImportExportResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ImportExtensionProperties represents the properties for an import operation +type ImportExtensionProperties struct { + // OperationMode - The type of import operation being performed. This is always Import. + OperationMode *string `json:"operationMode,omitempty"` + // 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"` +} + +// ImportExtensionRequest import database parameters. +type ImportExtensionRequest struct { + // Name - The name of the extension. + Name *string `json:"name,omitempty"` + // Type - The type of the extension. + Type *string `json:"type,omitempty"` + // ImportExtensionProperties - Represents the properties of the resource. + *ImportExtensionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExtensionRequest. +func (ier ImportExtensionRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ier.Name != nil { + objectMap["name"] = ier.Name + } + if ier.Type != nil { + objectMap["type"] = ier.Type + } + if ier.ImportExtensionProperties != nil { + objectMap["properties"] = ier.ImportExtensionProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ier.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ier.Type = &typeVar + } + case "properties": + if v != nil { + var importExtensionProperties ImportExtensionProperties + err = json.Unmarshal(*v, &importExtensionProperties) + if err != nil { + return err + } + ier.ImportExtensionProperties = &importExtensionProperties + } + } + } + + return nil +} + +// ImportRequest import database parameters. +type ImportRequest struct { + // DatabaseName - The name of the database to import. + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - The edition for the database being created. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or one of the following commands: + // + // ```azurecli + // az sql db list-editions -l -o table + // ```` + // + // ```powershell + // Get-AzSqlServerServiceObjective -Location + // ```` + // . Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2', 'GeneralPurpose', 'BusinessCritical', 'Hyperscale' + 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"` + // 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"` +} + +// LocationCapabilities the location capability. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationCapabilities. +func (lc LocationCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lc.Reason != nil { + objectMap["reason"] = lc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstance an Azure SQL managed instance. +type ManagedInstance struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the managed instance. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Sku - Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, BC_Gen5 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstance. +func (mi ManagedInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mi.Identity != nil { + objectMap["identity"] = mi.Identity + } + if mi.Sku != nil { + objectMap["sku"] = mi.Sku + } + if mi.ManagedInstanceProperties != nil { + objectMap["properties"] = mi.ManagedInstanceProperties + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.Tags != nil { + objectMap["tags"] = mi.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstance struct. +func (mi *ManagedInstance) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mi.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + mi.Sku = &sku + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + mi.ManagedInstanceProperties = &managedInstanceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mi.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceListResult a list of managed instances. +type ManagedInstanceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceListResult. +func (milr ManagedInstanceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// NextWithContext 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 *ManagedInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceListResultIterator) 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 ManagedInstanceListResultIterator) Response() ManagedInstanceListResult { + 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 ManagedInstanceListResultIterator) Value() ManagedInstance { + if !iter.page.NotDone() { + return ManagedInstance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceListResultIterator type. +func NewManagedInstanceListResultIterator(page ManagedInstanceListResultPage) ManagedInstanceListResultIterator { + return ManagedInstanceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (milr ManagedInstanceListResult) hasNextLink() bool { + return milr.NextLink != nil && len(*milr.NextLink) != 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !milr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// NextWithContext 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 *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.milr) + if err != nil { + return err + } + page.milr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceListResultPage) NotDone() bool { + return !page.milr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceListResultPage) Response() ManagedInstanceListResult { + return page.milr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceListResultPage) Values() []ManagedInstance { + if page.milr.IsEmpty() { + return nil + } + return *page.milr.Value +} + +// Creates a new instance of the ManagedInstanceListResultPage type. +func NewManagedInstanceListResultPage(cur ManagedInstanceListResult, getNextPage func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error)) ManagedInstanceListResultPage { + return ManagedInstanceListResultPage{ + fn: getNextPage, + milr: cur, + } +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // ManagedInstanceCreateMode - Specifies the mode of database creation. + // + // Default: Regular instance creation. + // + // Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: 'ManagedServerCreateModeDefault', 'ManagedServerCreateModePointInTimeRestore' + ManagedInstanceCreateMode ManagedServerCreateMode `json:"managedInstanceCreateMode,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the managed instance. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // AdministratorLogin - Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for managed instance creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // SubnetID - Subnet resource ID for the managed instance. + SubnetID *string `json:"subnetId,omitempty"` + // State - READ-ONLY; The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Possible values include: 'LicenseIncluded', 'BasePrice' + LicenseType ManagedInstanceLicenseType `json:"licenseType,omitempty"` + // VCores - The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - Storage size in GB. Minimum value: 32. Maximum value: 8192. Increments of 32 GB allowed only. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` + // Collation - Collation of the managed instance. + Collation *string `json:"collation,omitempty"` + // DNSZone - READ-ONLY; The Dns Zone that the managed instance is in. + DNSZone *string `json:"dnsZone,omitempty"` + // DNSZonePartner - The resource id of another managed instance whose DNS zone this managed instance will share after creation. + DNSZonePartner *string `json:"dnsZonePartner,omitempty"` + // PublicDataEndpointEnabled - Whether or not the public data endpoint is enabled. + PublicDataEndpointEnabled *bool `json:"publicDataEndpointEnabled,omitempty"` + // SourceManagedInstanceID - The resource identifier of the source managed instance associated with create operation of this instance. + SourceManagedInstanceID *string `json:"sourceManagedInstanceId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // ProxyOverride - Connection type used for connecting to the instance. Possible values include: 'ManagedInstanceProxyOverrideProxy', 'ManagedInstanceProxyOverrideRedirect', 'ManagedInstanceProxyOverrideDefault' + ProxyOverride ManagedInstanceProxyOverride `json:"proxyOverride,omitempty"` + // TimezoneID - Id of the timezone. Allowed values are timezones supported by Windows. + // Windows keeps details on supported timezones, including the id, in registry under + // KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. + // You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM sys.time_zone_info. + // List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. + // An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". + TimezoneID *string `json:"timezoneId,omitempty"` + // InstancePoolID - The Id of the instance pool this managed server belongs to. + InstancePoolID *string `json:"instancePoolId,omitempty"` + // MaintenanceConfigurationID - Specifies maintenance configuration id to apply to this managed instance. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // MinimalTLSVersion - Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2' + MinimalTLSVersion *string `json:"minimalTlsVersion,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceProperties. +func (mip ManagedInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mip.ManagedInstanceCreateMode != "" { + objectMap["managedInstanceCreateMode"] = mip.ManagedInstanceCreateMode + } + if mip.AdministratorLogin != nil { + objectMap["administratorLogin"] = mip.AdministratorLogin + } + if mip.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = mip.AdministratorLoginPassword + } + if mip.SubnetID != nil { + objectMap["subnetId"] = mip.SubnetID + } + if mip.LicenseType != "" { + objectMap["licenseType"] = mip.LicenseType + } + if mip.VCores != nil { + objectMap["vCores"] = mip.VCores + } + if mip.StorageSizeInGB != nil { + objectMap["storageSizeInGB"] = mip.StorageSizeInGB + } + if mip.Collation != nil { + objectMap["collation"] = mip.Collation + } + if mip.DNSZonePartner != nil { + objectMap["dnsZonePartner"] = mip.DNSZonePartner + } + if mip.PublicDataEndpointEnabled != nil { + objectMap["publicDataEndpointEnabled"] = mip.PublicDataEndpointEnabled + } + if mip.SourceManagedInstanceID != nil { + objectMap["sourceManagedInstanceId"] = mip.SourceManagedInstanceID + } + if mip.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mip.RestorePointInTime + } + if mip.ProxyOverride != "" { + objectMap["proxyOverride"] = mip.ProxyOverride + } + if mip.TimezoneID != nil { + objectMap["timezoneId"] = mip.TimezoneID + } + if mip.InstancePoolID != nil { + objectMap["instancePoolId"] = mip.InstancePoolID + } + if mip.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = mip.MaintenanceConfigurationID + } + if mip.MinimalTLSVersion != nil { + objectMap["minimalTlsVersion"] = mip.MinimalTLSVersion + } + return json.Marshal(objectMap) +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesCreateOrUpdateFuture.Result. +func (future *ManagedInstancesCreateOrUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.CreateOrUpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesDeleteFuture.Result. +func (future *ManagedInstancesDeleteFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesUpdateFuture.Result. +func (future *ManagedInstancesUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.UpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceUpdate an update request for an Azure SQL Database managed instance. +type ManagedInstanceUpdate struct { + // Sku - Managed instance sku + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceUpdate. +func (miu ManagedInstanceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miu.Sku != nil { + objectMap["sku"] = miu.Sku + } + if miu.ManagedInstanceProperties != nil { + objectMap["properties"] = miu.ManagedInstanceProperties + } + if miu.Tags != nil { + objectMap["tags"] = miu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceUpdate struct. +func (miu *ManagedInstanceUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + miu.Sku = &sku + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + miu.ManagedInstanceProperties = &managedInstanceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + miu.Tags = tags + } + } + } + + return nil +} + +// MaxSizeCapability the maximum size capability. +type MaxSizeCapability struct { + // Limit - READ-ONLY; The maximum size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes' + Unit MaxSizeUnits `json:"unit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeCapability. +func (msc MaxSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if msc.Reason != nil { + objectMap["reason"] = msc.Reason + } + return json.Marshal(objectMap) +} + +// Metric database metrics. +type Metric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time step to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for Metric. +func (mVar Metric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricAvailability a metric availability value. +type MetricAvailability struct { + // Retention - READ-ONLY; The length of retention for the database metric. + Retention *string `json:"retention,omitempty"` + // TimeGrain - READ-ONLY; The granularity of the database metric. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAvailability. +func (ma MetricAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinition a database metric definition. +type MetricDefinition struct { + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // PrimaryAggregationType - READ-ONLY; The primary aggregation type defining how metric values are displayed. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeCount', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeTotal' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // ResourceURI - READ-ONLY; The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond' + Unit UnitDefinitionType `json:"unit,omitempty"` + // MetricAvailabilities - READ-ONLY; The list of database metric availabilities for the metric. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDefinition. +func (md MetricDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinitionListResult the response to a list database metric definitions request. +type MetricDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of metric definitions for the database. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricListResult the response to a list database metrics request. +type MetricListResult struct { + autorest.Response `json:"-"` + // Value - The list of metrics for the database. + Value *[]Metric `json:"value,omitempty"` +} + +// MetricName a database metric name. +type MetricName struct { + // Value - READ-ONLY; The name of the database metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - READ-ONLY; The friendly name of the database metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricName. +func (mn MetricName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricValue represents database metrics. +type MetricValue struct { + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricValue. +func (mv MetricValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Operation SQL REST API operation definition. +type Operation struct { + // Name - READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The localized display information for this particular operation / action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. Possible values include: 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - READ-ONLY; Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The localized friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationImpact the impact of an operation, both in absolute and relative terms. +type OperationImpact struct { + // Name - READ-ONLY; The name of the impact dimension. + Name *string `json:"name,omitempty"` + // Unit - READ-ONLY; The unit in which estimated impact to dimension is measured. + Unit *string `json:"unit,omitempty"` + // ChangeValueAbsolute - READ-ONLY; The absolute impact to dimension. + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - READ-ONLY; The relative impact to dimension (null if not applicable) + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationImpact. +func (oi OperationImpact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult result of the request to list SQL operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PartnerInfo partner server information for the failover group. +type PartnerInfo struct { + // ID - Resource identifier of the partner server. + ID *string `json:"id,omitempty"` + // Location - READ-ONLY; Geo location of the partner server. + Location *string `json:"location,omitempty"` + // ReplicationRole - READ-ONLY; Replication role of the partner server. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartnerInfo. +func (pi PartnerInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pi.ID != nil { + objectMap["id"] = pi.ID + } + return json.Marshal(objectMap) +} + +// PerformanceLevelCapability the performance level capability. +type PerformanceLevelCapability struct { + // Value - READ-ONLY; Performance level value. + Value *int32 `json:"value,omitempty"` + // Unit - READ-ONLY; Unit type used to measure service objective performance level. Possible values include: 'DTU' + Unit PerformanceLevelUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for PerformanceLevelCapability. +func (plc PerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecommendedIndex represents a database recommended index. +type RecommendedIndex struct { + // RecommendedIndexProperties - READ-ONLY; The properties representing the resource. + *RecommendedIndexProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedIndex. +func (ri RecommendedIndex) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecommendedIndex struct. +func (ri *RecommendedIndex) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recommendedIndexProperties RecommendedIndexProperties + err = json.Unmarshal(*v, &recommendedIndexProperties) + if err != nil { + return err + } + ri.RecommendedIndexProperties = &recommendedIndexProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ri.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ri.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ri.Type = &typeVar + } + } + } + + return nil +} + +// RecommendedIndexProperties represents the properties of a database recommended index. +type RecommendedIndexProperties struct { + // Action - READ-ONLY; 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 - READ-ONLY; The current recommendation state. Possible values include: 'Active', 'Pending', 'Executing', 'Verifying', 'PendingRevert', 'Reverting', 'Reverted', 'Ignored', 'Expired', 'Blocked', 'Success' + State RecommendedIndexState `json:"state,omitempty"` + // Created - READ-ONLY; The UTC datetime showing when this resource was created (ISO8601 format). + Created *date.Time `json:"created,omitempty"` + // LastModified - READ-ONLY; The UTC datetime of when was this resource last changed (ISO8601 format). + LastModified *date.Time `json:"lastModified,omitempty"` + // IndexType - READ-ONLY; The type of index (CLUSTERED, NONCLUSTERED, COLUMNSTORE, CLUSTERED COLUMNSTORE). Possible values include: 'CLUSTERED', 'NONCLUSTERED', 'COLUMNSTORE', 'CLUSTEREDCOLUMNSTORE' + IndexType RecommendedIndexType `json:"indexType,omitempty"` + // Schema - READ-ONLY; The schema where table to build index over resides + Schema *string `json:"schema,omitempty"` + // Table - READ-ONLY; The table on which to build index. + Table *string `json:"table,omitempty"` + // Columns - READ-ONLY; Columns over which to build index + Columns *[]string `json:"columns,omitempty"` + // IncludedColumns - READ-ONLY; The list of column names to be included in the index + IncludedColumns *[]string `json:"includedColumns,omitempty"` + // IndexScript - READ-ONLY; The full build index script + IndexScript *string `json:"indexScript,omitempty"` + // EstimatedImpact - READ-ONLY; The estimated impact of doing recommended index action. + EstimatedImpact *[]OperationImpact `json:"estimatedImpact,omitempty"` + // ReportedImpact - READ-ONLY; The values reported after index action is complete. + ReportedImpact *[]OperationImpact `json:"reportedImpact,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedIndexProperties. +func (rip RecommendedIndexProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableDatabase a recoverable database +type RecoverableDatabase struct { + autorest.Response `json:"-"` + // RecoverableDatabaseProperties - The properties of a recoverable database + *RecoverableDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableDatabase. +func (rd RecoverableDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.RecoverableDatabaseProperties != nil { + objectMap["properties"] = rd.RecoverableDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableDatabase struct. +func (rd *RecoverableDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recoverableDatabaseProperties RecoverableDatabaseProperties + err = json.Unmarshal(*v, &recoverableDatabaseProperties) + if err != nil { + return err + } + rd.RecoverableDatabaseProperties = &recoverableDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rd.Type = &typeVar + } + } + } + + return nil +} + +// RecoverableDatabaseListResult the response to a list recoverable databases request +type RecoverableDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - A list of recoverable databases + Value *[]RecoverableDatabase `json:"value,omitempty"` +} + +// RecoverableDatabaseProperties the properties of a recoverable database +type RecoverableDatabaseProperties struct { + // Edition - READ-ONLY; The edition of the database + Edition *string `json:"edition,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - READ-ONLY; The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // LastAvailableBackupDate - READ-ONLY; The last available backup date of the database (ISO8601 format) + LastAvailableBackupDate *date.Time `json:"lastAvailableBackupDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableDatabaseProperties. +func (rdp RecoverableDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLink represents a database replication link. +type ReplicationLink struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Location of the server that contains this firewall rule. + Location *string `json:"location,omitempty"` + // ReplicationLinkProperties - The properties representing the resource. + *ReplicationLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLink. +func (rl ReplicationLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rl.ReplicationLinkProperties != nil { + objectMap["properties"] = rl.ReplicationLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ReplicationLink struct. +func (rl *ReplicationLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rl.Location = &location + } + case "properties": + if v != nil { + var replicationLinkProperties ReplicationLinkProperties + err = json.Unmarshal(*v, &replicationLinkProperties) + if err != nil { + return err + } + rl.ReplicationLinkProperties = &replicationLinkProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rl.Type = &typeVar + } + } + } + + return nil +} + +// ReplicationLinkListResult represents the response to a List database replication link request. +type ReplicationLinkListResult struct { + autorest.Response `json:"-"` + // Value - The list of database replication links housed in the database. + Value *[]ReplicationLink `json:"value,omitempty"` +} + +// ReplicationLinkProperties represents the properties of a database replication link. +type ReplicationLinkProperties struct { + // IsTerminationAllowed - READ-ONLY; Legacy value indicating whether termination is allowed. Currently always returns true. + IsTerminationAllowed *bool `json:"isTerminationAllowed,omitempty"` + // ReplicationMode - READ-ONLY; Replication mode of this replication link. + ReplicationMode *string `json:"replicationMode,omitempty"` + // PartnerServer - READ-ONLY; The name of the server hosting the partner database. + PartnerServer *string `json:"partnerServer,omitempty"` + // PartnerDatabase - READ-ONLY; The name of the partner database. + PartnerDatabase *string `json:"partnerDatabase,omitempty"` + // PartnerLocation - READ-ONLY; The Azure Region of the partner database. + PartnerLocation *string `json:"partnerLocation,omitempty"` + // Role - READ-ONLY; The role of the database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + Role ReplicationRole `json:"role,omitempty"` + // PartnerRole - READ-ONLY; The role of the partner database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + PartnerRole ReplicationRole `json:"partnerRole,omitempty"` + // StartTime - READ-ONLY; The start time for the replication link. + StartTime *date.Time `json:"startTime,omitempty"` + // PercentComplete - READ-ONLY; The percentage of seeding complete for the replication link. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ReplicationState - READ-ONLY; The replication state for the replication link. Possible values include: 'PENDING', 'SEEDING', 'CATCHUP', 'SUSPENDED' + ReplicationState ReplicationState `json:"replicationState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLinkProperties. +func (rlp ReplicationLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLinksFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ReplicationLinksFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksFailoverAllowDataLossFuture.Result. +func (future *ReplicationLinksFailoverAllowDataLossFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") + return + } + ar.Response = future.Response() + return +} + +// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ReplicationLinksFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksFailoverFuture.Result. +func (future *ReplicationLinksFailoverFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ReplicationLinksUnlinkFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReplicationLinksUnlinkFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksUnlinkFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksUnlinkFuture.Result. +func (future *ReplicationLinksUnlinkFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksUnlinkFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksUnlinkFuture") + return + } + ar.Response = future.Response() + return +} + +// Resource ARM resource. +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceIdentity azure Active Directory identity configuration for a resource. +type ResourceIdentity struct { + // PrincipalID - READ-ONLY; The Azure Active Directory principal id. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned' + Type IdentityType `json:"type,omitempty"` + // TenantID - READ-ONLY; The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceIdentity. +func (ri ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ri.Type != "" { + objectMap["type"] = ri.Type + } + return json.Marshal(objectMap) +} + +// RestorableDroppedDatabase a restorable dropped database +type RestorableDroppedDatabase struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // RestorableDroppedDatabaseProperties - The properties of a restorable dropped database + *RestorableDroppedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabase. +func (rdd RestorableDroppedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdd.RestorableDroppedDatabaseProperties != nil { + objectMap["properties"] = rdd.RestorableDroppedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDroppedDatabase struct. +func (rdd *RestorableDroppedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdd.Location = &location + } + case "properties": + if v != nil { + var restorableDroppedDatabaseProperties RestorableDroppedDatabaseProperties + err = json.Unmarshal(*v, &restorableDroppedDatabaseProperties) + if err != nil { + return err + } + rdd.RestorableDroppedDatabaseProperties = &restorableDroppedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rdd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rdd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rdd.Type = &typeVar + } + } + } + + return nil +} + +// RestorableDroppedDatabaseListResult the response to a list restorable dropped databases request +type RestorableDroppedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - A list of restorable dropped databases + Value *[]RestorableDroppedDatabase `json:"value,omitempty"` +} + +// RestorableDroppedDatabaseProperties the properties of a restorable dropped database +type RestorableDroppedDatabaseProperties struct { + // DatabaseName - READ-ONLY; The name of the database + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - READ-ONLY; The edition of the database + Edition *string `json:"edition,omitempty"` + // MaxSizeBytes - READ-ONLY; The max size in bytes of the database + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - READ-ONLY; The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format) + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - READ-ONLY; The deletion date of the database (ISO8601 format) + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore date of the database (ISO8601 format) + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabaseProperties. +func (rddp RestorableDroppedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePoint a database restore point. +type RestorePoint struct { + // RestorePointProperties - The properties of the restore point. + *RestorePointProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePoint. +func (rp RestorePoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RestorePointProperties != nil { + objectMap["properties"] = rp.RestorePointProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorePoint struct. +func (rp *RestorePoint) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorePointProperties RestorePointProperties + err = json.Unmarshal(*v, &restorePointProperties) + if err != nil { + return err + } + rp.RestorePointProperties = &restorePointProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rp.Type = &typeVar + } + } + } + + return nil +} + +// RestorePointListResult the response to a list database restore points request. +type RestorePointListResult struct { + autorest.Response `json:"-"` + // Value - The list of database restore points. + Value *[]RestorePoint `json:"value,omitempty"` +} + +// RestorePointProperties represents the properties of a database restore point. +type RestorePointProperties struct { + // RestorePointType - READ-ONLY; The restore point type of the database restore point. Possible values include: 'DISCRETE', 'CONTINUOUS' + RestorePointType RestorePointType `json:"restorePointType,omitempty"` + // RestorePointCreationDate - READ-ONLY; Restore point creation time (ISO8601 format). Populated when restorePointType = CONTINUOUS. Null otherwise. + RestorePointCreationDate *date.Time `json:"restorePointCreationDate,omitempty"` + // EarliestRestoreDate - READ-ONLY; Earliest restore time (ISO8601 format). Populated when restorePointType = DISCRETE. Null otherwise. + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePointProperties. +func (rpp RestorePointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Server an Azure SQL Database server. +type Server struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the server. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Kind - READ-ONLY; Kind of sql server. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ServerProperties - Resource properties. + *ServerProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Identity != nil { + objectMap["identity"] = s.Identity + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Server struct. +func (s *Server) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + s.Kind = &kind + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServerAdministratorListResult the response to a list Active Directory Administrators request. +type ServerAdministratorListResult struct { + autorest.Response `json:"-"` + // Value - The list of server Active Directory Administrators for the server. + Value *[]ServerAzureADAdministrator `json:"value,omitempty"` +} + +// ServerAdministratorProperties the properties of an server Administrator. +type ServerAdministratorProperties struct { + // AdministratorType - The type of administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - The server administrator login value. + Login *string `json:"login,omitempty"` + // Sid - The server administrator Sid (Secure ID). + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - The server Active Directory Administrator tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// ServerAzureADAdministrator an server Active Directory Administrator. +type ServerAzureADAdministrator struct { + autorest.Response `json:"-"` + // ServerAdministratorProperties - The properties of the resource. + *ServerAdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAzureADAdministrator. +func (saaa ServerAzureADAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if saaa.ServerAdministratorProperties != nil { + objectMap["properties"] = saaa.ServerAdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAzureADAdministrator struct. +func (saaa *ServerAzureADAdministrator) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverAdministratorProperties ServerAdministratorProperties + err = json.Unmarshal(*v, &serverAdministratorProperties) + if err != nil { + return err + } + saaa.ServerAdministratorProperties = &serverAdministratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + saaa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + saaa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + saaa.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerAzureADAdministratorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADAdministratorsClient) (ServerAzureADAdministrator, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADAdministratorsCreateOrUpdateFuture.Result. +func (future *ServerAzureADAdministratorsCreateOrUpdateFuture) result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + saaa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaa.Response.Response, err = future.GetResult(sender); err == nil && saaa.Response.Response.StatusCode != http.StatusNoContent { + saaa, err = client.CreateOrUpdateResponder(saaa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", saaa.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerAzureADAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerAzureADAdministratorsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADAdministratorsClient) (ServerAzureADAdministrator, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADAdministratorsDeleteFuture.Result. +func (future *ServerAzureADAdministratorsDeleteFuture) result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + saaa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaa.Response.Response, err = future.GetResult(sender); err == nil && saaa.Response.Response.StatusCode != http.StatusNoContent { + saaa, err = client.DeleteResponder(saaa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", saaa.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerCommunicationLink server communication link. +type ServerCommunicationLink struct { + autorest.Response `json:"-"` + // ServerCommunicationLinkProperties - The properties of resource. + *ServerCommunicationLinkProperties `json:"properties,omitempty"` + // Location - READ-ONLY; Communication link location. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; Communication link kind. This property is used for Azure Portal metadata. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerCommunicationLink. +func (scl ServerCommunicationLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scl.ServerCommunicationLinkProperties != nil { + objectMap["properties"] = scl.ServerCommunicationLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerCommunicationLink struct. +func (scl *ServerCommunicationLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverCommunicationLinkProperties ServerCommunicationLinkProperties + err = json.Unmarshal(*v, &serverCommunicationLinkProperties) + if err != nil { + return err + } + scl.ServerCommunicationLinkProperties = &serverCommunicationLinkProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scl.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + scl.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scl.Type = &typeVar + } + } + } + + return nil +} + +// ServerCommunicationLinkListResult a list of server communication links. +type ServerCommunicationLinkListResult struct { + autorest.Response `json:"-"` + // Value - The list of server communication links. + Value *[]ServerCommunicationLink `json:"value,omitempty"` +} + +// ServerCommunicationLinkProperties the properties of a server communication link. +type ServerCommunicationLinkProperties struct { + // State - READ-ONLY; The state. + State *string `json:"state,omitempty"` + // PartnerServer - The name of the partner server. + PartnerServer *string `json:"partnerServer,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerCommunicationLinkProperties. +func (sclp ServerCommunicationLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sclp.PartnerServer != nil { + objectMap["partnerServer"] = sclp.PartnerServer + } + return json.Marshal(objectMap) +} + +// ServerCommunicationLinksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerCommunicationLinksCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerCommunicationLinksClient) (ServerCommunicationLink, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerCommunicationLinksCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerCommunicationLinksCreateOrUpdateFuture.Result. +func (future *ServerCommunicationLinksCreateOrUpdateFuture) result(client ServerCommunicationLinksClient) (scl ServerCommunicationLink, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + scl.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if scl.Response.Response, err = future.GetResult(sender); err == nil && scl.Response.Response.StatusCode != http.StatusNoContent { + scl, err = client.CreateOrUpdateResponder(scl.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", scl.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerConnectionPolicy a server secure connection policy. +type ServerConnectionPolicy struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // ServerConnectionPolicyProperties - The properties of the server secure connection policy. + *ServerConnectionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerConnectionPolicy. +func (scp ServerConnectionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.ServerConnectionPolicyProperties != nil { + objectMap["properties"] = scp.ServerConnectionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerConnectionPolicy struct. +func (scp *ServerConnectionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + scp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scp.Location = &location + } + case "properties": + if v != nil { + var serverConnectionPolicyProperties ServerConnectionPolicyProperties + err = json.Unmarshal(*v, &serverConnectionPolicyProperties) + if err != nil { + return err + } + scp.ServerConnectionPolicyProperties = &serverConnectionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scp.Type = &typeVar + } + } + } + + return nil +} + +// ServerConnectionPolicyProperties the properties of a server secure connection policy. +type ServerConnectionPolicyProperties struct { + // ConnectionType - The server connection type. Possible values include: 'ServerConnectionTypeDefault', 'ServerConnectionTypeProxy', 'ServerConnectionTypeRedirect' + ConnectionType ServerConnectionType `json:"connectionType,omitempty"` +} + +// ServerKey a server key. +type ServerKey struct { + autorest.Response `json:"-"` + // Kind - Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // ServerKeyProperties - Resource properties. + *ServerKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKey. +func (sk ServerKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sk.Kind != nil { + objectMap["kind"] = sk.Kind + } + if sk.ServerKeyProperties != nil { + objectMap["properties"] = sk.ServerKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerKey struct. +func (sk *ServerKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + sk.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sk.Location = &location + } + case "properties": + if v != nil { + var serverKeyProperties ServerKeyProperties + err = json.Unmarshal(*v, &serverKeyProperties) + if err != nil { + return err + } + sk.ServerKeyProperties = &serverKeyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sk.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sk.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sk.Type = &typeVar + } + } + } + + return nil +} + +// ServerKeyListResult a list of server keys. +type ServerKeyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerKey `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKeyListResult. +func (sklr ServerKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerKeyListResultIterator provides access to a complete listing of ServerKey values. +type ServerKeyListResultIterator struct { + i int + page ServerKeyListResultPage +} + +// NextWithContext 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 *ServerKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerKeyListResultIterator) 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 ServerKeyListResultIterator) Response() ServerKeyListResult { + 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 ServerKeyListResultIterator) Value() ServerKey { + if !iter.page.NotDone() { + return ServerKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerKeyListResultIterator type. +func NewServerKeyListResultIterator(page ServerKeyListResultPage) ServerKeyListResultIterator { + return ServerKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sklr ServerKeyListResult) IsEmpty() bool { + return sklr.Value == nil || len(*sklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sklr ServerKeyListResult) hasNextLink() bool { + return sklr.NextLink != nil && len(*sklr.NextLink) != 0 +} + +// serverKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sklr ServerKeyListResult) serverKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sklr.NextLink))) +} + +// ServerKeyListResultPage contains a page of ServerKey values. +type ServerKeyListResultPage struct { + fn func(context.Context, ServerKeyListResult) (ServerKeyListResult, error) + sklr ServerKeyListResult +} + +// NextWithContext 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 *ServerKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sklr) + if err != nil { + return err + } + page.sklr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerKeyListResultPage) NotDone() bool { + return !page.sklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerKeyListResultPage) Response() ServerKeyListResult { + return page.sklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerKeyListResultPage) Values() []ServerKey { + if page.sklr.IsEmpty() { + return nil + } + return *page.sklr.Value +} + +// Creates a new instance of the ServerKeyListResultPage type. +func NewServerKeyListResultPage(cur ServerKeyListResult, getNextPage func(context.Context, ServerKeyListResult) (ServerKeyListResult, error)) ServerKeyListResultPage { + return ServerKeyListResultPage{ + fn: getNextPage, + sklr: cur, + } +} + +// ServerKeyProperties properties for a server key execution. +type ServerKeyProperties struct { + // Subregion - READ-ONLY; Subregion of the server key. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyType - The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - The server key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKeyProperties. +func (skp ServerKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if skp.ServerKeyType != "" { + objectMap["serverKeyType"] = skp.ServerKeyType + } + if skp.URI != nil { + objectMap["uri"] = skp.URI + } + if skp.Thumbprint != nil { + objectMap["thumbprint"] = skp.Thumbprint + } + if skp.CreationDate != nil { + objectMap["creationDate"] = skp.CreationDate + } + return json.Marshal(objectMap) +} + +// ServerKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerKeysCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerKeysClient) (ServerKey, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerKeysCreateOrUpdateFuture.Result. +func (future *ServerKeysCreateOrUpdateFuture) result(client ServerKeysClient) (sk ServerKey, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sk.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sk.Response.Response, err = future.GetResult(sender); err == nil && sk.Response.Response.StatusCode != http.StatusNoContent { + sk, err = client.CreateOrUpdateResponder(sk.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", sk.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerKeysDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerKeysClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerKeysDeleteFuture.Result. +func (future *ServerKeysDeleteFuture) result(client ServerKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Server `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerListResult. +func (slr ServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// NextWithContext 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 *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerListResultIterator) 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 ServerListResultIterator) Response() ServerListResult { + 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 ServerListResultIterator) Value() Server { + if !iter.page.NotDone() { + return Server{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerListResultIterator type. +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return ServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServerListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer(ctx context.Context) (*http.Request, error) { + if !slr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(context.Context, ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// NextWithContext 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 *ServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerListResultPage) Response() ServerListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerListResultPage) Values() []Server { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServerListResultPage type. +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return ServerListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - Administrator username for the server. Once created it cannot be changed. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - The version of the server. + Version *string `json:"version,omitempty"` + // State - READ-ONLY; The state of the server. + State *string `json:"state,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerProperties. +func (sp ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AdministratorLogin != nil { + objectMap["administratorLogin"] = sp.AdministratorLogin + } + if sp.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword + } + if sp.Version != nil { + objectMap["version"] = sp.Version + } + return json.Marshal(objectMap) +} + +// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersCreateOrUpdateFuture.Result. +func (future *ServersCreateOrUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateOrUpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerUpdate an update request for an Azure SQL Database server. +type ServerUpdate struct { + // ServerProperties - Resource properties. + *ServerProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerUpdate. +func (su ServerUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if su.ServerProperties != nil { + objectMap["properties"] = su.ServerProperties + } + if su.Tags != nil { + objectMap["tags"] = su.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerUpdate struct. +func (su *ServerUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + su.ServerProperties = &serverProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + su.Tags = tags + } + } + } + + return nil +} + +// ServerUsage represents server metrics. +type ServerUsage struct { + // Name - READ-ONLY; Name of the server usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - READ-ONLY; The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - READ-ONLY; The metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; The current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; The current limit of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units of the metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - READ-ONLY; The next reset time for the metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerUsage. +func (su ServerUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerUsageListResult represents the response to a list server metrics request. +type ServerUsageListResult struct { + autorest.Response `json:"-"` + // Value - The list of server metrics for the server. + Value *[]ServerUsage `json:"value,omitempty"` +} + +// ServerVersionCapability the server capability +type ServerVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - READ-ONLY; The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if svc.Reason != nil { + objectMap["reason"] = svc.Reason + } + return json.Marshal(objectMap) +} + +// ServiceLevelObjectiveCapability the service objectives capability. +type ServiceLevelObjectiveCapability struct { + // ID - READ-ONLY; The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // Name - READ-ONLY; The service objective name. + Name *string `json:"name,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported maximum database sizes for this service objective. + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + // PerformanceLevel - READ-ONLY; The performance level of the service objective capability. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size for this service level objective. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceLevelObjectiveCapability. +func (sloc ServiceLevelObjectiveCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sloc.Reason != nil { + objectMap["reason"] = sloc.Reason + } + return json.Marshal(objectMap) +} + +// ServiceObjective represents a database service objective. +type ServiceObjective struct { + autorest.Response `json:"-"` + // ServiceObjectiveProperties - Represents the properties of the resource. + *ServiceObjectiveProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjective. +func (so ServiceObjective) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if so.ServiceObjectiveProperties != nil { + objectMap["properties"] = so.ServiceObjectiveProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceObjective struct. +func (so *ServiceObjective) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceObjectiveProperties ServiceObjectiveProperties + err = json.Unmarshal(*v, &serviceObjectiveProperties) + if err != nil { + return err + } + so.ServiceObjectiveProperties = &serviceObjectiveProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + so.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + so.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + so.Type = &typeVar + } + } + } + + return nil +} + +// ServiceObjectiveListResult represents the response to a get database service objectives request. +type ServiceObjectiveListResult struct { + autorest.Response `json:"-"` + // Value - The list of database service objectives. + Value *[]ServiceObjective `json:"value,omitempty"` +} + +// ServiceObjectiveProperties represents the properties of a database service objective. +type ServiceObjectiveProperties struct { + // ServiceObjectiveName - READ-ONLY; The name for the service objective. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // IsDefault - READ-ONLY; Gets whether the service level objective is the default service objective. + IsDefault *bool `json:"isDefault,omitempty"` + // IsSystem - READ-ONLY; Gets whether the service level objective is a system service objective. + IsSystem *bool `json:"isSystem,omitempty"` + // Description - READ-ONLY; The description for the service level objective. + Description *string `json:"description,omitempty"` + // Enabled - READ-ONLY; Gets whether the service level objective is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveProperties. +func (sop ServiceObjectiveProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServiceTierAdvisor represents a Service Tier Advisor. +type ServiceTierAdvisor struct { + autorest.Response `json:"-"` + // ServiceTierAdvisorProperties - READ-ONLY; The properties representing the resource. + *ServiceTierAdvisorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceTierAdvisor. +func (sta ServiceTierAdvisor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceTierAdvisor struct. +func (sta *ServiceTierAdvisor) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceTierAdvisorProperties ServiceTierAdvisorProperties + err = json.Unmarshal(*v, &serviceTierAdvisorProperties) + if err != nil { + return err + } + sta.ServiceTierAdvisorProperties = &serviceTierAdvisorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sta.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sta.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sta.Type = &typeVar + } + } + } + + return nil +} + +// ServiceTierAdvisorListResult represents the response to a list service tier advisor request. +type ServiceTierAdvisorListResult struct { + autorest.Response `json:"-"` + // Value - The list of service tier advisors for specified database. + Value *[]ServiceTierAdvisor `json:"value,omitempty"` +} + +// ServiceTierAdvisorProperties represents the properties of a Service Tier Advisor. +type ServiceTierAdvisorProperties struct { + // ObservationPeriodStart - READ-ONLY; The observation period start (ISO8601 format). + ObservationPeriodStart *date.Time `json:"observationPeriodStart,omitempty"` + // ObservationPeriodEnd - READ-ONLY; The observation period start (ISO8601 format). + ObservationPeriodEnd *date.Time `json:"observationPeriodEnd,omitempty"` + // ActiveTimeRatio - READ-ONLY; The activeTimeRatio for service tier advisor. + ActiveTimeRatio *float64 `json:"activeTimeRatio,omitempty"` + // MinDtu - READ-ONLY; Gets or sets minDtu for service tier advisor. + MinDtu *float64 `json:"minDtu,omitempty"` + // AvgDtu - READ-ONLY; Gets or sets avgDtu for service tier advisor. + AvgDtu *float64 `json:"avgDtu,omitempty"` + // MaxDtu - READ-ONLY; Gets or sets maxDtu for service tier advisor. + MaxDtu *float64 `json:"maxDtu,omitempty"` + // MaxSizeInGB - READ-ONLY; Gets or sets maxSizeInGB for service tier advisor. + MaxSizeInGB *float64 `json:"maxSizeInGB,omitempty"` + // ServiceLevelObjectiveUsageMetrics - READ-ONLY; Gets or sets serviceLevelObjectiveUsageMetrics for the service tier advisor. + ServiceLevelObjectiveUsageMetrics *[]SloUsageMetric `json:"serviceLevelObjectiveUsageMetrics,omitempty"` + // CurrentServiceLevelObjective - READ-ONLY; Gets or sets currentServiceLevelObjective for service tier advisor. + CurrentServiceLevelObjective *string `json:"currentServiceLevelObjective,omitempty"` + // CurrentServiceLevelObjectiveID - READ-ONLY; Gets or sets currentServiceLevelObjectiveId for service tier advisor. + CurrentServiceLevelObjectiveID *uuid.UUID `json:"currentServiceLevelObjectiveId,omitempty"` + // UsageBasedRecommendationServiceLevelObjective - READ-ONLY; Gets or sets usageBasedRecommendationServiceLevelObjective for service tier advisor. + UsageBasedRecommendationServiceLevelObjective *string `json:"usageBasedRecommendationServiceLevelObjective,omitempty"` + // UsageBasedRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets usageBasedRecommendationServiceLevelObjectiveId for service tier advisor. + UsageBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"usageBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjective - READ-ONLY; Gets or sets databaseSizeBasedRecommendationServiceLevelObjective for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjective *string `json:"databaseSizeBasedRecommendationServiceLevelObjective,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets databaseSizeBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"databaseSizeBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjective - READ-ONLY; Gets or sets disasterPlanBasedRecommendationServiceLevelObjective for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjective *string `json:"disasterPlanBasedRecommendationServiceLevelObjective,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets disasterPlanBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"disasterPlanBasedRecommendationServiceLevelObjectiveId,omitempty"` + // OverallRecommendationServiceLevelObjective - READ-ONLY; Gets or sets overallRecommendationServiceLevelObjective for service tier advisor. + OverallRecommendationServiceLevelObjective *string `json:"overallRecommendationServiceLevelObjective,omitempty"` + // OverallRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets overallRecommendationServiceLevelObjectiveId for service tier advisor. + OverallRecommendationServiceLevelObjectiveID *uuid.UUID `json:"overallRecommendationServiceLevelObjectiveId,omitempty"` + // Confidence - READ-ONLY; Gets or sets confidence for service tier advisor. + Confidence *float64 `json:"confidence,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceTierAdvisorProperties. +func (stap ServiceTierAdvisorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku an ARM Resource SKU. +type Sku struct { + // Name - The name of the SKU, typically, a letter + Number code, e.g. P3. + Name *string `json:"name,omitempty"` + // Tier - The tier or edition of the particular SKU, e.g. Basic, Premium. + Tier *string `json:"tier,omitempty"` + // Size - Size of the particular SKU + Size *string `json:"size,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // Capacity - Capacity of the particular SKU. + Capacity *int32 `json:"capacity,omitempty"` +} + +// SloUsageMetric a Slo Usage Metric. +type SloUsageMetric struct { + // ServiceLevelObjective - READ-ONLY; The serviceLevelObjective for SLO usage metric. 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' + ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` + // ServiceLevelObjectiveID - READ-ONLY; The serviceLevelObjectiveId for SLO usage metric. + ServiceLevelObjectiveID *uuid.UUID `json:"serviceLevelObjectiveId,omitempty"` + // InRangeTimeRatio - READ-ONLY; Gets or sets inRangeTimeRatio for SLO usage metric. + InRangeTimeRatio *float64 `json:"inRangeTimeRatio,omitempty"` +} + +// MarshalJSON is the custom marshaler for SloUsageMetric. +func (sum SloUsageMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SubscriptionUsage usage Metric of a Subscription in a Location. +type SubscriptionUsage struct { + autorest.Response `json:"-"` + // SubscriptionUsageProperties - Resource properties. + *SubscriptionUsageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsage. +func (su SubscriptionUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if su.SubscriptionUsageProperties != nil { + objectMap["properties"] = su.SubscriptionUsageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionUsage struct. +func (su *SubscriptionUsage) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subscriptionUsageProperties SubscriptionUsageProperties + err = json.Unmarshal(*v, &subscriptionUsageProperties) + if err != nil { + return err + } + su.SubscriptionUsageProperties = &subscriptionUsageProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + su.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + su.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + su.Type = &typeVar + } + } + } + + return nil +} + +// SubscriptionUsageListResult a list of subscription usage metrics in a location. +type SubscriptionUsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SubscriptionUsage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsageListResult. +func (sulr SubscriptionUsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SubscriptionUsageListResultIterator provides access to a complete listing of SubscriptionUsage values. +type SubscriptionUsageListResultIterator struct { + i int + page SubscriptionUsageListResultPage +} + +// NextWithContext 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 *SubscriptionUsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SubscriptionUsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubscriptionUsageListResultIterator) 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 SubscriptionUsageListResultIterator) Response() SubscriptionUsageListResult { + 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 SubscriptionUsageListResultIterator) Value() SubscriptionUsage { + if !iter.page.NotDone() { + return SubscriptionUsage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubscriptionUsageListResultIterator type. +func NewSubscriptionUsageListResultIterator(page SubscriptionUsageListResultPage) SubscriptionUsageListResultIterator { + return SubscriptionUsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sulr SubscriptionUsageListResult) IsEmpty() bool { + return sulr.Value == nil || len(*sulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sulr SubscriptionUsageListResult) hasNextLink() bool { + return sulr.NextLink != nil && len(*sulr.NextLink) != 0 +} + +// subscriptionUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sulr SubscriptionUsageListResult) subscriptionUsageListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sulr.NextLink))) +} + +// SubscriptionUsageListResultPage contains a page of SubscriptionUsage values. +type SubscriptionUsageListResultPage struct { + fn func(context.Context, SubscriptionUsageListResult) (SubscriptionUsageListResult, error) + sulr SubscriptionUsageListResult +} + +// NextWithContext 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 *SubscriptionUsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sulr) + if err != nil { + return err + } + page.sulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SubscriptionUsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubscriptionUsageListResultPage) NotDone() bool { + return !page.sulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubscriptionUsageListResultPage) Response() SubscriptionUsageListResult { + return page.sulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubscriptionUsageListResultPage) Values() []SubscriptionUsage { + if page.sulr.IsEmpty() { + return nil + } + return *page.sulr.Value +} + +// Creates a new instance of the SubscriptionUsageListResultPage type. +func NewSubscriptionUsageListResultPage(cur SubscriptionUsageListResult, getNextPage func(context.Context, SubscriptionUsageListResult) (SubscriptionUsageListResult, error)) SubscriptionUsageListResultPage { + return SubscriptionUsageListResultPage{ + fn: getNextPage, + sulr: cur, + } +} + +// SubscriptionUsageProperties properties of a subscription usage. +type SubscriptionUsageProperties struct { + // DisplayName - READ-ONLY; User-readable name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; Current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Boundary value of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit of the metric. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsageProperties. +func (sup SubscriptionUsageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgent an Azure SQL Database sync agent. +type SyncAgent struct { + autorest.Response `json:"-"` + // SyncAgentProperties - Resource properties. + *SyncAgentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgent. +func (sa SyncAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sa.SyncAgentProperties != nil { + objectMap["properties"] = sa.SyncAgentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncAgent struct. +func (sa *SyncAgent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncAgentProperties SyncAgentProperties + err = json.Unmarshal(*v, &syncAgentProperties) + if err != nil { + return err + } + sa.SyncAgentProperties = &syncAgentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sa.Type = &typeVar + } + } + } + + return nil +} + +// SyncAgentKeyProperties properties of an Azure SQL Database sync agent key. +type SyncAgentKeyProperties struct { + autorest.Response `json:"-"` + // SyncAgentKey - READ-ONLY; Key of sync agent. + SyncAgentKey *string `json:"syncAgentKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentKeyProperties. +func (sakp SyncAgentKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentLinkedDatabase an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabase struct { + // SyncAgentLinkedDatabaseProperties - Resource properties. + *SyncAgentLinkedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabase. +func (sald SyncAgentLinkedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sald.SyncAgentLinkedDatabaseProperties != nil { + objectMap["properties"] = sald.SyncAgentLinkedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncAgentLinkedDatabase struct. +func (sald *SyncAgentLinkedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncAgentLinkedDatabaseProperties SyncAgentLinkedDatabaseProperties + err = json.Unmarshal(*v, &syncAgentLinkedDatabaseProperties) + if err != nil { + return err + } + sald.SyncAgentLinkedDatabaseProperties = &syncAgentLinkedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sald.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sald.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sald.Type = &typeVar + } + } + } + + return nil +} + +// SyncAgentLinkedDatabaseListResult a list of sync agent linked databases. +type SyncAgentLinkedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncAgentLinkedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabaseListResult. +func (saldlr SyncAgentLinkedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentLinkedDatabaseListResultIterator provides access to a complete listing of +// SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultIterator struct { + i int + page SyncAgentLinkedDatabaseListResultPage +} + +// NextWithContext 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 *SyncAgentLinkedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentLinkedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncAgentLinkedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncAgentLinkedDatabaseListResultIterator) 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 SyncAgentLinkedDatabaseListResultIterator) Response() SyncAgentLinkedDatabaseListResult { + 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 SyncAgentLinkedDatabaseListResultIterator) Value() SyncAgentLinkedDatabase { + if !iter.page.NotDone() { + return SyncAgentLinkedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncAgentLinkedDatabaseListResultIterator type. +func NewSyncAgentLinkedDatabaseListResultIterator(page SyncAgentLinkedDatabaseListResultPage) SyncAgentLinkedDatabaseListResultIterator { + return SyncAgentLinkedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (saldlr SyncAgentLinkedDatabaseListResult) IsEmpty() bool { + return saldlr.Value == nil || len(*saldlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (saldlr SyncAgentLinkedDatabaseListResult) hasNextLink() bool { + return saldlr.NextLink != nil && len(*saldlr.NextLink) != 0 +} + +// syncAgentLinkedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (saldlr SyncAgentLinkedDatabaseListResult) syncAgentLinkedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !saldlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(saldlr.NextLink))) +} + +// SyncAgentLinkedDatabaseListResultPage contains a page of SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultPage struct { + fn func(context.Context, SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error) + saldlr SyncAgentLinkedDatabaseListResult +} + +// NextWithContext 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 *SyncAgentLinkedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentLinkedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.saldlr) + if err != nil { + return err + } + page.saldlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncAgentLinkedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncAgentLinkedDatabaseListResultPage) NotDone() bool { + return !page.saldlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncAgentLinkedDatabaseListResultPage) Response() SyncAgentLinkedDatabaseListResult { + return page.saldlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncAgentLinkedDatabaseListResultPage) Values() []SyncAgentLinkedDatabase { + if page.saldlr.IsEmpty() { + return nil + } + return *page.saldlr.Value +} + +// Creates a new instance of the SyncAgentLinkedDatabaseListResultPage type. +func NewSyncAgentLinkedDatabaseListResultPage(cur SyncAgentLinkedDatabaseListResult, getNextPage func(context.Context, SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error)) SyncAgentLinkedDatabaseListResultPage { + return SyncAgentLinkedDatabaseListResultPage{ + fn: getNextPage, + saldlr: cur, + } +} + +// SyncAgentLinkedDatabaseProperties properties of an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabaseProperties struct { + // DatabaseType - READ-ONLY; Type of the sync agent linked database. Possible values include: 'AzureSQLDatabase', 'SQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // DatabaseID - READ-ONLY; Id of the sync agent linked database. + DatabaseID *string `json:"databaseId,omitempty"` + // Description - READ-ONLY; Description of the sync agent linked database. + Description *string `json:"description,omitempty"` + // ServerName - READ-ONLY; Server name of the sync agent linked database. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name of the sync agent linked database. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - READ-ONLY; User name of the sync agent linked database. + UserName *string `json:"userName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabaseProperties. +func (saldp SyncAgentLinkedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentListResult a list of sync agents. +type SyncAgentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncAgent `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentListResult. +func (salr SyncAgentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentListResultIterator provides access to a complete listing of SyncAgent values. +type SyncAgentListResultIterator struct { + i int + page SyncAgentListResultPage +} + +// NextWithContext 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 *SyncAgentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncAgentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncAgentListResultIterator) 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 SyncAgentListResultIterator) Response() SyncAgentListResult { + 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 SyncAgentListResultIterator) Value() SyncAgent { + if !iter.page.NotDone() { + return SyncAgent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncAgentListResultIterator type. +func NewSyncAgentListResultIterator(page SyncAgentListResultPage) SyncAgentListResultIterator { + return SyncAgentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (salr SyncAgentListResult) IsEmpty() bool { + return salr.Value == nil || len(*salr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (salr SyncAgentListResult) hasNextLink() bool { + return salr.NextLink != nil && len(*salr.NextLink) != 0 +} + +// syncAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (salr SyncAgentListResult) syncAgentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !salr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(salr.NextLink))) +} + +// SyncAgentListResultPage contains a page of SyncAgent values. +type SyncAgentListResultPage struct { + fn func(context.Context, SyncAgentListResult) (SyncAgentListResult, error) + salr SyncAgentListResult +} + +// NextWithContext 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 *SyncAgentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.salr) + if err != nil { + return err + } + page.salr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncAgentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncAgentListResultPage) NotDone() bool { + return !page.salr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncAgentListResultPage) Response() SyncAgentListResult { + return page.salr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncAgentListResultPage) Values() []SyncAgent { + if page.salr.IsEmpty() { + return nil + } + return *page.salr.Value +} + +// Creates a new instance of the SyncAgentListResultPage type. +func NewSyncAgentListResultPage(cur SyncAgentListResult, getNextPage func(context.Context, SyncAgentListResult) (SyncAgentListResult, error)) SyncAgentListResultPage { + return SyncAgentListResultPage{ + fn: getNextPage, + salr: cur, + } +} + +// SyncAgentProperties properties of an Azure SQL Database sync agent. +type SyncAgentProperties struct { + // Name - READ-ONLY; Name of the sync agent. + Name *string `json:"name,omitempty"` + // SyncDatabaseID - ARM resource id of the sync database in the sync agent. + SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` + // LastAliveTime - READ-ONLY; Last alive time of the sync agent. + LastAliveTime *date.Time `json:"lastAliveTime,omitempty"` + // State - READ-ONLY; State of the sync agent. Possible values include: 'Online', 'Offline', 'NeverConnected' + State SyncAgentState `json:"state,omitempty"` + // IsUpToDate - READ-ONLY; If the sync agent version is up to date. + IsUpToDate *bool `json:"isUpToDate,omitempty"` + // ExpiryTime - READ-ONLY; Expiration time of the sync agent version. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Version - READ-ONLY; Version of the sync agent. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentProperties. +func (sap SyncAgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sap.SyncDatabaseID != nil { + objectMap["syncDatabaseId"] = sap.SyncDatabaseID + } + return json.Marshal(objectMap) +} + +// SyncAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncAgentsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncAgentsClient) (SyncAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncAgentsCreateOrUpdateFuture.Result. +func (future *SyncAgentsCreateOrUpdateFuture) result(client SyncAgentsClient) (sa SyncAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sa.Response.Response, err = future.GetResult(sender); err == nil && sa.Response.Response.StatusCode != http.StatusNoContent { + sa, err = client.CreateOrUpdateResponder(sa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", sa.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncAgentsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncAgentsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncAgentsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncAgentsDeleteFuture.Result. +func (future *SyncAgentsDeleteFuture) result(client SyncAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncDatabaseIDListResult a list of sync database ID properties. +type SyncDatabaseIDListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncDatabaseIDProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncDatabaseIDListResult. +func (sdilr SyncDatabaseIDListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncDatabaseIDListResultIterator provides access to a complete listing of SyncDatabaseIDProperties +// values. +type SyncDatabaseIDListResultIterator struct { + i int + page SyncDatabaseIDListResultPage +} + +// NextWithContext 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 *SyncDatabaseIDListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncDatabaseIDListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncDatabaseIDListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncDatabaseIDListResultIterator) 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 SyncDatabaseIDListResultIterator) Response() SyncDatabaseIDListResult { + 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 SyncDatabaseIDListResultIterator) Value() SyncDatabaseIDProperties { + if !iter.page.NotDone() { + return SyncDatabaseIDProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncDatabaseIDListResultIterator type. +func NewSyncDatabaseIDListResultIterator(page SyncDatabaseIDListResultPage) SyncDatabaseIDListResultIterator { + return SyncDatabaseIDListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdilr SyncDatabaseIDListResult) IsEmpty() bool { + return sdilr.Value == nil || len(*sdilr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdilr SyncDatabaseIDListResult) hasNextLink() bool { + return sdilr.NextLink != nil && len(*sdilr.NextLink) != 0 +} + +// syncDatabaseIDListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdilr SyncDatabaseIDListResult) syncDatabaseIDListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdilr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdilr.NextLink))) +} + +// SyncDatabaseIDListResultPage contains a page of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultPage struct { + fn func(context.Context, SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error) + sdilr SyncDatabaseIDListResult +} + +// NextWithContext 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 *SyncDatabaseIDListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncDatabaseIDListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdilr) + if err != nil { + return err + } + page.sdilr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncDatabaseIDListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncDatabaseIDListResultPage) NotDone() bool { + return !page.sdilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncDatabaseIDListResultPage) Response() SyncDatabaseIDListResult { + return page.sdilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncDatabaseIDListResultPage) Values() []SyncDatabaseIDProperties { + if page.sdilr.IsEmpty() { + return nil + } + return *page.sdilr.Value +} + +// Creates a new instance of the SyncDatabaseIDListResultPage type. +func NewSyncDatabaseIDListResultPage(cur SyncDatabaseIDListResult, getNextPage func(context.Context, SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error)) SyncDatabaseIDListResultPage { + return SyncDatabaseIDListResultPage{ + fn: getNextPage, + sdilr: cur, + } +} + +// SyncDatabaseIDProperties properties of the sync database id. +type SyncDatabaseIDProperties struct { + // ID - READ-ONLY; ARM resource id of sync database. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncDatabaseIDProperties. +func (sdip SyncDatabaseIDProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaProperties properties of the database full schema. +type SyncFullSchemaProperties struct { + // Tables - READ-ONLY; List of tables in the database full schema. + Tables *[]SyncFullSchemaTable `json:"tables,omitempty"` + // LastUpdateTime - READ-ONLY; Last update time of the database schema. + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaProperties. +func (sfsp SyncFullSchemaProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaPropertiesListResult a list of sync schema properties. +type SyncFullSchemaPropertiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncFullSchemaProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaPropertiesListResult. +func (sfsplr SyncFullSchemaPropertiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaPropertiesListResultIterator provides access to a complete listing of +// SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultIterator struct { + i int + page SyncFullSchemaPropertiesListResultPage +} + +// NextWithContext 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 *SyncFullSchemaPropertiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncFullSchemaPropertiesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncFullSchemaPropertiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncFullSchemaPropertiesListResultIterator) 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 SyncFullSchemaPropertiesListResultIterator) Response() SyncFullSchemaPropertiesListResult { + 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 SyncFullSchemaPropertiesListResultIterator) Value() SyncFullSchemaProperties { + if !iter.page.NotDone() { + return SyncFullSchemaProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncFullSchemaPropertiesListResultIterator type. +func NewSyncFullSchemaPropertiesListResultIterator(page SyncFullSchemaPropertiesListResultPage) SyncFullSchemaPropertiesListResultIterator { + return SyncFullSchemaPropertiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sfsplr SyncFullSchemaPropertiesListResult) IsEmpty() bool { + return sfsplr.Value == nil || len(*sfsplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sfsplr SyncFullSchemaPropertiesListResult) hasNextLink() bool { + return sfsplr.NextLink != nil && len(*sfsplr.NextLink) != 0 +} + +// syncFullSchemaPropertiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sfsplr SyncFullSchemaPropertiesListResult) syncFullSchemaPropertiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sfsplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sfsplr.NextLink))) +} + +// SyncFullSchemaPropertiesListResultPage contains a page of SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultPage struct { + fn func(context.Context, SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error) + sfsplr SyncFullSchemaPropertiesListResult +} + +// NextWithContext 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 *SyncFullSchemaPropertiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncFullSchemaPropertiesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sfsplr) + if err != nil { + return err + } + page.sfsplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncFullSchemaPropertiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncFullSchemaPropertiesListResultPage) NotDone() bool { + return !page.sfsplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncFullSchemaPropertiesListResultPage) Response() SyncFullSchemaPropertiesListResult { + return page.sfsplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncFullSchemaPropertiesListResultPage) Values() []SyncFullSchemaProperties { + if page.sfsplr.IsEmpty() { + return nil + } + return *page.sfsplr.Value +} + +// Creates a new instance of the SyncFullSchemaPropertiesListResultPage type. +func NewSyncFullSchemaPropertiesListResultPage(cur SyncFullSchemaPropertiesListResult, getNextPage func(context.Context, SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error)) SyncFullSchemaPropertiesListResultPage { + return SyncFullSchemaPropertiesListResultPage{ + fn: getNextPage, + sfsplr: cur, + } +} + +// SyncFullSchemaTable properties of the table in the database full schema. +type SyncFullSchemaTable struct { + // Columns - READ-ONLY; List of columns in the table of database full schema. + Columns *[]SyncFullSchemaTableColumn `json:"columns,omitempty"` + // ErrorID - READ-ONLY; Error id of the table. + ErrorID *string `json:"errorId,omitempty"` + // HasError - READ-ONLY; If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // Name - READ-ONLY; Name of the table. + Name *string `json:"name,omitempty"` + // QuotedName - READ-ONLY; Quoted name of the table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaTable. +func (sfst SyncFullSchemaTable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaTableColumn properties of the column in the table of database full schema. +type SyncFullSchemaTableColumn struct { + // DataSize - READ-ONLY; Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - READ-ONLY; Data type of the column. + DataType *string `json:"dataType,omitempty"` + // ErrorID - READ-ONLY; Error id of the column. + ErrorID *string `json:"errorId,omitempty"` + // HasError - READ-ONLY; If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // IsPrimaryKey - READ-ONLY; If it is the primary key of the table. + IsPrimaryKey *bool `json:"isPrimaryKey,omitempty"` + // Name - READ-ONLY; Name of the column. + Name *string `json:"name,omitempty"` + // QuotedName - READ-ONLY; Quoted name of the column. + QuotedName *string `json:"quotedName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaTableColumn. +func (sfstc SyncFullSchemaTableColumn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroup an Azure SQL Database sync group. +type SyncGroup struct { + autorest.Response `json:"-"` + // SyncGroupProperties - Resource properties. + *SyncGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroup. +func (sg SyncGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sg.SyncGroupProperties != nil { + objectMap["properties"] = sg.SyncGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncGroup struct. +func (sg *SyncGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncGroupProperties SyncGroupProperties + err = json.Unmarshal(*v, &syncGroupProperties) + if err != nil { + return err + } + sg.SyncGroupProperties = &syncGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sg.Type = &typeVar + } + } + } + + return nil +} + +// SyncGroupListResult a list of sync groups. +type SyncGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupListResult. +func (sglr SyncGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupListResultIterator provides access to a complete listing of SyncGroup values. +type SyncGroupListResultIterator struct { + i int + page SyncGroupListResultPage +} + +// NextWithContext 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 *SyncGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncGroupListResultIterator) 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 SyncGroupListResultIterator) Response() SyncGroupListResult { + 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 SyncGroupListResultIterator) Value() SyncGroup { + if !iter.page.NotDone() { + return SyncGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncGroupListResultIterator type. +func NewSyncGroupListResultIterator(page SyncGroupListResultPage) SyncGroupListResultIterator { + return SyncGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sglr SyncGroupListResult) IsEmpty() bool { + return sglr.Value == nil || len(*sglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sglr SyncGroupListResult) hasNextLink() bool { + return sglr.NextLink != nil && len(*sglr.NextLink) != 0 +} + +// syncGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sglr SyncGroupListResult) syncGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sglr.NextLink))) +} + +// SyncGroupListResultPage contains a page of SyncGroup values. +type SyncGroupListResultPage struct { + fn func(context.Context, SyncGroupListResult) (SyncGroupListResult, error) + sglr SyncGroupListResult +} + +// NextWithContext 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 *SyncGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sglr) + if err != nil { + return err + } + page.sglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncGroupListResultPage) NotDone() bool { + return !page.sglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncGroupListResultPage) Response() SyncGroupListResult { + return page.sglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncGroupListResultPage) Values() []SyncGroup { + if page.sglr.IsEmpty() { + return nil + } + return *page.sglr.Value +} + +// Creates a new instance of the SyncGroupListResultPage type. +func NewSyncGroupListResultPage(cur SyncGroupListResult, getNextPage func(context.Context, SyncGroupListResult) (SyncGroupListResult, error)) SyncGroupListResultPage { + return SyncGroupListResultPage{ + fn: getNextPage, + sglr: cur, + } +} + +// SyncGroupLogListResult a list of sync group log properties. +type SyncGroupLogListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncGroupLogProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupLogListResult. +func (sgllr SyncGroupLogListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupLogListResultIterator provides access to a complete listing of SyncGroupLogProperties values. +type SyncGroupLogListResultIterator struct { + i int + page SyncGroupLogListResultPage +} + +// NextWithContext 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 *SyncGroupLogListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupLogListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncGroupLogListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncGroupLogListResultIterator) 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 SyncGroupLogListResultIterator) Response() SyncGroupLogListResult { + 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 SyncGroupLogListResultIterator) Value() SyncGroupLogProperties { + if !iter.page.NotDone() { + return SyncGroupLogProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncGroupLogListResultIterator type. +func NewSyncGroupLogListResultIterator(page SyncGroupLogListResultPage) SyncGroupLogListResultIterator { + return SyncGroupLogListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sgllr SyncGroupLogListResult) IsEmpty() bool { + return sgllr.Value == nil || len(*sgllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sgllr SyncGroupLogListResult) hasNextLink() bool { + return sgllr.NextLink != nil && len(*sgllr.NextLink) != 0 +} + +// syncGroupLogListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sgllr SyncGroupLogListResult) syncGroupLogListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sgllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sgllr.NextLink))) +} + +// SyncGroupLogListResultPage contains a page of SyncGroupLogProperties values. +type SyncGroupLogListResultPage struct { + fn func(context.Context, SyncGroupLogListResult) (SyncGroupLogListResult, error) + sgllr SyncGroupLogListResult +} + +// NextWithContext 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 *SyncGroupLogListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupLogListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sgllr) + if err != nil { + return err + } + page.sgllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncGroupLogListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncGroupLogListResultPage) NotDone() bool { + return !page.sgllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncGroupLogListResultPage) Response() SyncGroupLogListResult { + return page.sgllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncGroupLogListResultPage) Values() []SyncGroupLogProperties { + if page.sgllr.IsEmpty() { + return nil + } + return *page.sgllr.Value +} + +// Creates a new instance of the SyncGroupLogListResultPage type. +func NewSyncGroupLogListResultPage(cur SyncGroupLogListResult, getNextPage func(context.Context, SyncGroupLogListResult) (SyncGroupLogListResult, error)) SyncGroupLogListResultPage { + return SyncGroupLogListResultPage{ + fn: getNextPage, + sgllr: cur, + } +} + +// SyncGroupLogProperties properties of an Azure SQL Database sync group log. +type SyncGroupLogProperties struct { + // Timestamp - READ-ONLY; Timestamp of the sync group log. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Type - READ-ONLY; Type of the sync group log. Possible values include: 'SyncGroupLogTypeAll', 'SyncGroupLogTypeError', 'SyncGroupLogTypeWarning', 'SyncGroupLogTypeSuccess' + Type SyncGroupLogType `json:"type,omitempty"` + // Source - READ-ONLY; Source of the sync group log. + Source *string `json:"source,omitempty"` + // Details - READ-ONLY; Details of the sync group log. + Details *string `json:"details,omitempty"` + // TracingID - READ-ONLY; TracingId of the sync group log. + TracingID *uuid.UUID `json:"tracingId,omitempty"` + // OperationStatus - READ-ONLY; OperationStatus of the sync group log. + OperationStatus *string `json:"operationStatus,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupLogProperties. +func (sglp SyncGroupLogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupProperties properties of a sync group. +type SyncGroupProperties struct { + // Interval - Sync interval of the sync group. + Interval *int32 `json:"interval,omitempty"` + // LastSyncTime - READ-ONLY; Last sync time of the sync group. + LastSyncTime *date.Time `json:"lastSyncTime,omitempty"` + // ConflictResolutionPolicy - Conflict resolution policy of the sync group. Possible values include: 'HubWin', 'MemberWin' + ConflictResolutionPolicy SyncConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // SyncDatabaseID - ARM resource id of the sync database in the sync group. + SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` + // HubDatabaseUserName - User name for the sync group hub database credential. + HubDatabaseUserName *string `json:"hubDatabaseUserName,omitempty"` + // HubDatabasePassword - Password for the sync group hub database credential. + HubDatabasePassword *string `json:"hubDatabasePassword,omitempty"` + // SyncState - READ-ONLY; 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"` +} + +// MarshalJSON is the custom marshaler for SyncGroupProperties. +func (sgp SyncGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sgp.Interval != nil { + objectMap["interval"] = sgp.Interval + } + if sgp.ConflictResolutionPolicy != "" { + objectMap["conflictResolutionPolicy"] = sgp.ConflictResolutionPolicy + } + if sgp.SyncDatabaseID != nil { + objectMap["syncDatabaseId"] = sgp.SyncDatabaseID + } + if sgp.HubDatabaseUserName != nil { + objectMap["hubDatabaseUserName"] = sgp.HubDatabaseUserName + } + if sgp.HubDatabasePassword != nil { + objectMap["hubDatabasePassword"] = sgp.HubDatabasePassword + } + if sgp.Schema != nil { + objectMap["schema"] = sgp.Schema + } + return json.Marshal(objectMap) +} + +// SyncGroupSchema properties of sync group schema. +type SyncGroupSchema struct { + // Tables - List of tables in sync group schema. + Tables *[]SyncGroupSchemaTable `json:"tables,omitempty"` + // MasterSyncMemberName - Name of master sync member where the schema is from. + MasterSyncMemberName *string `json:"masterSyncMemberName,omitempty"` +} + +// SyncGroupSchemaTable properties of table in sync group schema. +type SyncGroupSchemaTable struct { + // Columns - List of columns in sync group schema. + Columns *[]SyncGroupSchemaTableColumn `json:"columns,omitempty"` + // QuotedName - Quoted name of sync group schema table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncGroupSchemaTableColumn properties of column in sync group table. +type SyncGroupSchemaTableColumn struct { + // QuotedName - Quoted name of sync group table column. + QuotedName *string `json:"quotedName,omitempty"` + // DataSize - Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - Data type of the column. + DataType *string `json:"dataType,omitempty"` +} + +// SyncGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (SyncGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsCreateOrUpdateFuture.Result. +func (future *SyncGroupsCreateOrUpdateFuture) result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent { + sg, err = client.CreateOrUpdateResponder(sg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", sg.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsDeleteFuture.Result. +func (future *SyncGroupsDeleteFuture) result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncGroupsRefreshHubSchemaFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncGroupsRefreshHubSchemaFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsRefreshHubSchemaFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsRefreshHubSchemaFuture.Result. +func (future *SyncGroupsRefreshHubSchemaFuture) result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (SyncGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsUpdateFuture.Result. +func (future *SyncGroupsUpdateFuture) result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent { + sg, err = client.UpdateResponder(sg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", sg.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncMember an Azure SQL Database sync member. +type SyncMember struct { + autorest.Response `json:"-"` + // SyncMemberProperties - Resource properties. + *SyncMemberProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMember. +func (sm SyncMember) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sm.SyncMemberProperties != nil { + objectMap["properties"] = sm.SyncMemberProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncMember struct. +func (sm *SyncMember) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncMemberProperties SyncMemberProperties + err = json.Unmarshal(*v, &syncMemberProperties) + if err != nil { + return err + } + sm.SyncMemberProperties = &syncMemberProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sm.Type = &typeVar + } + } + } + + return nil +} + +// SyncMemberListResult a list of Azure SQL Database sync members. +type SyncMemberListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncMember `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMemberListResult. +func (smlr SyncMemberListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncMemberListResultIterator provides access to a complete listing of SyncMember values. +type SyncMemberListResultIterator struct { + i int + page SyncMemberListResultPage +} + +// NextWithContext 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 *SyncMemberListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMemberListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncMemberListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncMemberListResultIterator) 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 SyncMemberListResultIterator) Response() SyncMemberListResult { + 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 SyncMemberListResultIterator) Value() SyncMember { + if !iter.page.NotDone() { + return SyncMember{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncMemberListResultIterator type. +func NewSyncMemberListResultIterator(page SyncMemberListResultPage) SyncMemberListResultIterator { + return SyncMemberListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (smlr SyncMemberListResult) IsEmpty() bool { + return smlr.Value == nil || len(*smlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (smlr SyncMemberListResult) hasNextLink() bool { + return smlr.NextLink != nil && len(*smlr.NextLink) != 0 +} + +// syncMemberListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smlr SyncMemberListResult) syncMemberListResultPreparer(ctx context.Context) (*http.Request, error) { + if !smlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smlr.NextLink))) +} + +// SyncMemberListResultPage contains a page of SyncMember values. +type SyncMemberListResultPage struct { + fn func(context.Context, SyncMemberListResult) (SyncMemberListResult, error) + smlr SyncMemberListResult +} + +// NextWithContext 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 *SyncMemberListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMemberListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.smlr) + if err != nil { + return err + } + page.smlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncMemberListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncMemberListResultPage) NotDone() bool { + return !page.smlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncMemberListResultPage) Response() SyncMemberListResult { + return page.smlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncMemberListResultPage) Values() []SyncMember { + if page.smlr.IsEmpty() { + return nil + } + return *page.smlr.Value +} + +// Creates a new instance of the SyncMemberListResultPage type. +func NewSyncMemberListResultPage(cur SyncMemberListResult, getNextPage func(context.Context, SyncMemberListResult) (SyncMemberListResult, error)) SyncMemberListResultPage { + return SyncMemberListResultPage{ + fn: getNextPage, + smlr: cur, + } +} + +// SyncMemberProperties properties of a sync member. +type SyncMemberProperties struct { + // DatabaseType - Database type of the sync member. Possible values include: 'AzureSQLDatabase', 'SQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // SyncAgentID - ARM resource id of the sync agent in the sync member. + SyncAgentID *string `json:"syncAgentId,omitempty"` + // SQLServerDatabaseID - SQL Server database id of the sync member. + SQLServerDatabaseID *uuid.UUID `json:"sqlServerDatabaseId,omitempty"` + // ServerName - Server name of the member database in the sync member + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - Database name of the member database in the sync member. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - User name of the member database in the sync member. + UserName *string `json:"userName,omitempty"` + // Password - Password of the member database in the sync member. + Password *string `json:"password,omitempty"` + // SyncDirection - Sync direction of the sync member. Possible values include: 'Bidirectional', 'OneWayMemberToHub', 'OneWayHubToMember' + SyncDirection SyncDirection `json:"syncDirection,omitempty"` + // SyncState - READ-ONLY; Sync state of the sync member. Possible values include: 'SyncInProgress', 'SyncSucceeded', 'SyncFailed', 'DisabledTombstoneCleanup', 'DisabledBackupRestore', 'SyncSucceededWithWarnings', 'SyncCancelling', 'SyncCancelled', 'UnProvisioned', 'Provisioning', 'Provisioned', 'ProvisionFailed', 'DeProvisioning', 'DeProvisioned', 'DeProvisionFailed', 'Reprovisioning', 'ReprovisionFailed', 'UnReprovisioned' + SyncState SyncMemberState `json:"syncState,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMemberProperties. +func (smp SyncMemberProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smp.DatabaseType != "" { + objectMap["databaseType"] = smp.DatabaseType + } + if smp.SyncAgentID != nil { + objectMap["syncAgentId"] = smp.SyncAgentID + } + if smp.SQLServerDatabaseID != nil { + objectMap["sqlServerDatabaseId"] = smp.SQLServerDatabaseID + } + if smp.ServerName != nil { + objectMap["serverName"] = smp.ServerName + } + if smp.DatabaseName != nil { + objectMap["databaseName"] = smp.DatabaseName + } + if smp.UserName != nil { + objectMap["userName"] = smp.UserName + } + if smp.Password != nil { + objectMap["password"] = smp.Password + } + if smp.SyncDirection != "" { + objectMap["syncDirection"] = smp.SyncDirection + } + return json.Marshal(objectMap) +} + +// SyncMembersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncMembersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (SyncMember, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersCreateOrUpdateFuture.Result. +func (future *SyncMembersCreateOrUpdateFuture) result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.CreateOrUpdateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncMembersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersDeleteFuture.Result. +func (future *SyncMembersDeleteFuture) result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncMembersRefreshMemberSchemaFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncMembersRefreshMemberSchemaFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersRefreshMemberSchemaFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersRefreshMemberSchemaFuture.Result. +func (future *SyncMembersRefreshMemberSchemaFuture) result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncMembersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (SyncMember, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersUpdateFuture.Result. +func (future *SyncMembersUpdateFuture) result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.UpdateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// TrackedResource ARM tracked top level resource. +type TrackedResource struct { + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// TransparentDataEncryption represents a database transparent data encryption configuration. +type TransparentDataEncryption struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionProperties - Represents the properties of the resource. + *TransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryption. +func (tde TransparentDataEncryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tde.TransparentDataEncryptionProperties != nil { + objectMap["properties"] = tde.TransparentDataEncryptionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryption struct. +func (tde *TransparentDataEncryption) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tde.Location = &location + } + case "properties": + if v != nil { + var transparentDataEncryptionProperties TransparentDataEncryptionProperties + err = json.Unmarshal(*v, &transparentDataEncryptionProperties) + if err != nil { + return err + } + tde.TransparentDataEncryptionProperties = &transparentDataEncryptionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tde.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tde.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tde.Type = &typeVar + } + } + } + + return nil +} + +// TransparentDataEncryptionActivity represents a database transparent data encryption Scan. +type TransparentDataEncryptionActivity struct { + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionActivityProperties - Represents the properties of the resource. + *TransparentDataEncryptionActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivity. +func (tdea TransparentDataEncryptionActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tdea.TransparentDataEncryptionActivityProperties != nil { + objectMap["properties"] = tdea.TransparentDataEncryptionActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryptionActivity struct. +func (tdea *TransparentDataEncryptionActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tdea.Location = &location + } + case "properties": + if v != nil { + var transparentDataEncryptionActivityProperties TransparentDataEncryptionActivityProperties + err = json.Unmarshal(*v, &transparentDataEncryptionActivityProperties) + if err != nil { + return err + } + tdea.TransparentDataEncryptionActivityProperties = &transparentDataEncryptionActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tdea.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tdea.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tdea.Type = &typeVar + } + } + } + + return nil +} + +// TransparentDataEncryptionActivityListResult represents the response to a list database transparent data +// encryption activity request. +type TransparentDataEncryptionActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of database transparent data encryption activities. + Value *[]TransparentDataEncryptionActivity `json:"value,omitempty"` +} + +// TransparentDataEncryptionActivityProperties represents the properties of a database transparent data +// encryption Scan. +type TransparentDataEncryptionActivityProperties struct { + // Status - READ-ONLY; The status of the database. Possible values include: 'Encrypting', 'Decrypting' + Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` + // PercentComplete - READ-ONLY; The percent complete of the transparent data encryption scan for a database. + PercentComplete *float64 `json:"percentComplete,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivityProperties. +func (tdeap TransparentDataEncryptionActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TransparentDataEncryptionProperties represents the properties of a database transparent data encryption. +type TransparentDataEncryptionProperties struct { + // Status - The status of the database transparent data encryption. Possible values include: 'TransparentDataEncryptionStatusEnabled', 'TransparentDataEncryptionStatusDisabled' + Status TransparentDataEncryptionStatus `json:"status,omitempty"` +} + +// UnlinkParameters represents the parameters for Unlink Replication Link request. +type UnlinkParameters struct { + // ForcedTermination - Determines whether link will be terminated in a forced or a friendly way. + ForcedTermination *bool `json:"forcedTermination,omitempty"` +} + +// VirtualCluster an Azure SQL virtual cluster. +type VirtualCluster struct { + autorest.Response `json:"-"` + // VirtualClusterProperties - Resource properties. + *VirtualClusterProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualCluster. +func (vc VirtualCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vc.VirtualClusterProperties != nil { + objectMap["properties"] = vc.VirtualClusterProperties + } + if vc.Location != nil { + objectMap["location"] = vc.Location + } + if vc.Tags != nil { + objectMap["tags"] = vc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualCluster struct. +func (vc *VirtualCluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualClusterProperties VirtualClusterProperties + err = json.Unmarshal(*v, &virtualClusterProperties) + if err != nil { + return err + } + vc.VirtualClusterProperties = &virtualClusterProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vc.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vc.Type = &typeVar + } + } + } + + return nil +} + +// VirtualClusterListResult a list of virtual clusters. +type VirtualClusterListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VirtualCluster `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterListResult. +func (vclr VirtualClusterListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualClusterListResultIterator provides access to a complete listing of VirtualCluster values. +type VirtualClusterListResultIterator struct { + i int + page VirtualClusterListResultPage +} + +// NextWithContext 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 *VirtualClusterListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClusterListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VirtualClusterListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VirtualClusterListResultIterator) 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 VirtualClusterListResultIterator) Response() VirtualClusterListResult { + 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 VirtualClusterListResultIterator) Value() VirtualCluster { + if !iter.page.NotDone() { + return VirtualCluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VirtualClusterListResultIterator type. +func NewVirtualClusterListResultIterator(page VirtualClusterListResultPage) VirtualClusterListResultIterator { + return VirtualClusterListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vclr VirtualClusterListResult) IsEmpty() bool { + return vclr.Value == nil || len(*vclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vclr VirtualClusterListResult) hasNextLink() bool { + return vclr.NextLink != nil && len(*vclr.NextLink) != 0 +} + +// virtualClusterListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vclr VirtualClusterListResult) virtualClusterListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vclr.NextLink))) +} + +// VirtualClusterListResultPage contains a page of VirtualCluster values. +type VirtualClusterListResultPage struct { + fn func(context.Context, VirtualClusterListResult) (VirtualClusterListResult, error) + vclr VirtualClusterListResult +} + +// NextWithContext 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 *VirtualClusterListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClusterListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vclr) + if err != nil { + return err + } + page.vclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VirtualClusterListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VirtualClusterListResultPage) NotDone() bool { + return !page.vclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VirtualClusterListResultPage) Response() VirtualClusterListResult { + return page.vclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VirtualClusterListResultPage) Values() []VirtualCluster { + if page.vclr.IsEmpty() { + return nil + } + return *page.vclr.Value +} + +// Creates a new instance of the VirtualClusterListResultPage type. +func NewVirtualClusterListResultPage(cur VirtualClusterListResult, getNextPage func(context.Context, VirtualClusterListResult) (VirtualClusterListResult, error)) VirtualClusterListResultPage { + return VirtualClusterListResultPage{ + fn: getNextPage, + vclr: cur, + } +} + +// VirtualClusterProperties the properties of a virtual cluster. +type VirtualClusterProperties struct { + // SubnetID - READ-ONLY; Subnet resource ID for the virtual cluster. + SubnetID *string `json:"subnetId,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // ChildResources - READ-ONLY; List of resources in this virtual cluster. + ChildResources *[]string `json:"childResources,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterProperties. +func (vcp VirtualClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcp.Family != nil { + objectMap["family"] = vcp.Family + } + return json.Marshal(objectMap) +} + +// VirtualClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualClustersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualClustersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualClustersDeleteFuture.Result. +func (future *VirtualClustersDeleteFuture) result(client VirtualClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// VirtualClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualClustersClient) (VirtualCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualClustersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualClustersUpdateFuture.Result. +func (future *VirtualClustersUpdateFuture) result(client VirtualClustersClient) (vc VirtualCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + vc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vc.Response.Response, err = future.GetResult(sender); err == nil && vc.Response.Response.StatusCode != http.StatusNoContent { + vc, err = client.UpdateResponder(vc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersUpdateFuture", "Result", vc.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualClusterUpdate an update request for an Azure SQL Database virtual cluster. +type VirtualClusterUpdate struct { + // VirtualClusterProperties - Resource properties. + *VirtualClusterProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterUpdate. +func (vcu VirtualClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcu.VirtualClusterProperties != nil { + objectMap["properties"] = vcu.VirtualClusterProperties + } + if vcu.Tags != nil { + objectMap["tags"] = vcu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualClusterUpdate struct. +func (vcu *VirtualClusterUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualClusterProperties VirtualClusterProperties + err = json.Unmarshal(*v, &virtualClusterProperties) + if err != nil { + return err + } + vcu.VirtualClusterProperties = &virtualClusterProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vcu.Tags = tags + } + } + } + + return nil +} + +// VirtualNetworkRule a virtual network rule. +type VirtualNetworkRule struct { + autorest.Response `json:"-"` + // VirtualNetworkRuleProperties - Resource properties. + *VirtualNetworkRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRule. +func (vnr VirtualNetworkRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnr.VirtualNetworkRuleProperties != nil { + objectMap["properties"] = vnr.VirtualNetworkRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualNetworkRule struct. +func (vnr *VirtualNetworkRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualNetworkRuleProperties VirtualNetworkRuleProperties + err = json.Unmarshal(*v, &virtualNetworkRuleProperties) + if err != nil { + return err + } + vnr.VirtualNetworkRuleProperties = &virtualNetworkRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vnr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vnr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vnr.Type = &typeVar + } + } + } + + return nil +} + +// VirtualNetworkRuleListResult a list of virtual network rules. +type VirtualNetworkRuleListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VirtualNetworkRule `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRuleListResult. +func (vnrlr VirtualNetworkRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkRuleListResultIterator provides access to a complete listing of VirtualNetworkRule values. +type VirtualNetworkRuleListResultIterator struct { + i int + page VirtualNetworkRuleListResultPage +} + +// NextWithContext 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 *VirtualNetworkRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VirtualNetworkRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VirtualNetworkRuleListResultIterator) 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 VirtualNetworkRuleListResultIterator) Response() VirtualNetworkRuleListResult { + 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 VirtualNetworkRuleListResultIterator) Value() VirtualNetworkRule { + if !iter.page.NotDone() { + return VirtualNetworkRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VirtualNetworkRuleListResultIterator type. +func NewVirtualNetworkRuleListResultIterator(page VirtualNetworkRuleListResultPage) VirtualNetworkRuleListResultIterator { + return VirtualNetworkRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vnrlr VirtualNetworkRuleListResult) IsEmpty() bool { + return vnrlr.Value == nil || len(*vnrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vnrlr VirtualNetworkRuleListResult) hasNextLink() bool { + return vnrlr.NextLink != nil && len(*vnrlr.NextLink) != 0 +} + +// virtualNetworkRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vnrlr VirtualNetworkRuleListResult) virtualNetworkRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vnrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vnrlr.NextLink))) +} + +// VirtualNetworkRuleListResultPage contains a page of VirtualNetworkRule values. +type VirtualNetworkRuleListResultPage struct { + fn func(context.Context, VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error) + vnrlr VirtualNetworkRuleListResult +} + +// NextWithContext 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 *VirtualNetworkRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vnrlr) + if err != nil { + return err + } + page.vnrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VirtualNetworkRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VirtualNetworkRuleListResultPage) NotDone() bool { + return !page.vnrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VirtualNetworkRuleListResultPage) Response() VirtualNetworkRuleListResult { + return page.vnrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VirtualNetworkRuleListResultPage) Values() []VirtualNetworkRule { + if page.vnrlr.IsEmpty() { + return nil + } + return *page.vnrlr.Value +} + +// Creates a new instance of the VirtualNetworkRuleListResultPage type. +func NewVirtualNetworkRuleListResultPage(cur VirtualNetworkRuleListResult, getNextPage func(context.Context, VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error)) VirtualNetworkRuleListResultPage { + return VirtualNetworkRuleListResultPage{ + fn: getNextPage, + vnrlr: cur, + } +} + +// VirtualNetworkRuleProperties properties of a virtual network rule. +type VirtualNetworkRuleProperties struct { + // VirtualNetworkSubnetID - The ARM resource id of the virtual network subnet. + VirtualNetworkSubnetID *string `json:"virtualNetworkSubnetId,omitempty"` + // IgnoreMissingVnetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled. + IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` + // State - READ-ONLY; Virtual Network Rule State. Possible values include: 'Initializing', 'InProgress', 'Ready', 'Deleting', 'Unknown' + State VirtualNetworkRuleState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRuleProperties. +func (vnrp VirtualNetworkRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnrp.VirtualNetworkSubnetID != nil { + objectMap["virtualNetworkSubnetId"] = vnrp.VirtualNetworkSubnetID + } + if vnrp.IgnoreMissingVnetServiceEndpoint != nil { + objectMap["ignoreMissingVnetServiceEndpoint"] = vnrp.IgnoreMissingVnetServiceEndpoint + } + return json.Marshal(objectMap) +} + +// VirtualNetworkRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualNetworkRulesClient) (VirtualNetworkRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualNetworkRulesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualNetworkRulesCreateOrUpdateFuture.Result. +func (future *VirtualNetworkRulesCreateOrUpdateFuture) result(client VirtualNetworkRulesClient) (vnr VirtualNetworkRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + vnr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vnr.Response.Response, err = future.GetResult(sender); err == nil && vnr.Response.Response.StatusCode != http.StatusNoContent { + vnr, err = client.CreateOrUpdateResponder(vnr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", vnr.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualNetworkRulesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualNetworkRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualNetworkRulesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualNetworkRulesDeleteFuture.Result. +func (future *VirtualNetworkRulesDeleteFuture) result(client VirtualNetworkRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/operations.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/operations.go new file mode 100644 index 000000000000..8d4ac613b1ce --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/operations.go @@ -0,0 +1,142 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// OperationsClient 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 OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available SQL Rest API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Sql/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/recoverabledatabases.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/recoverabledatabases.go new file mode 100644 index 000000000000..ef56a498903f --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/recoverabledatabases.go @@ -0,0 +1,190 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RecoverableDatabasesClient 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 RecoverableDatabasesClient struct { + BaseClient +} + +// NewRecoverableDatabasesClient creates an instance of the RecoverableDatabasesClient client. +func NewRecoverableDatabasesClient(subscriptionID string) RecoverableDatabasesClient { + return NewRecoverableDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableDatabasesClientWithBaseURI creates an instance of the RecoverableDatabasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewRecoverableDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RecoverableDatabasesClient { + return RecoverableDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable database, which is a resource representing a database's geo backup +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database +func (client RecoverableDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RecoverableDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "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.RecoverableDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableDatabasesClient) 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 = "2014-04-01" + 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}/recoverableDatabases/{databaseName}", 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 RecoverableDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) GetResponder(resp *http.Response) (result RecoverableDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of recoverable databases +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client RecoverableDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RecoverableDatabasesClient) 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 = "2014-04-01" + 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}/recoverableDatabases", 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 RecoverableDatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) ListByServerResponder(resp *http.Response) (result RecoverableDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/replicationlinks.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/replicationlinks.go new file mode 100644 index 000000000000..861e0db43427 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/replicationlinks.go @@ -0,0 +1,527 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ReplicationLinksClient 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 ReplicationLinksClient struct { + BaseClient +} + +// NewReplicationLinksClient creates an instance of the ReplicationLinksClient client. +func NewReplicationLinksClient(subscriptionID string) ReplicationLinksClient { + return NewReplicationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReplicationLinksClientWithBaseURI creates an instance of the ReplicationLinksClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewReplicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ReplicationLinksClient { + return ReplicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a database replication link. Cannot be done during failover. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be dropped. +// linkID - the ID of the replication link to be deleted. +func (client ReplicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/databases/{databaseName}/replicationLinks/{linkId}", 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 ReplicationLinksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover sets which replica database is primary by failing over from the current primary replica database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +func (client ReplicationLinksClient) Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ReplicationLinksClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/databases/{databaseName}/replicationLinks/{linkId}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) FailoverSender(req *http.Request) (future ReplicationLinksFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverAllowDataLoss sets which replica database is primary by failing over from the current primary replica +// database. This operation might result in data loss. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +func (client ReplicationLinksClient) FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.FailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverAllowDataLossPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "FailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.FailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "FailoverAllowDataLoss", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverAllowDataLossPreparer prepares the FailoverAllowDataLoss request. +func (client ReplicationLinksClient) FailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverAllowDataLossSender sends the FailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) FailoverAllowDataLossSender(req *http.Request) (future ReplicationLinksFailoverAllowDataLossFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverAllowDataLossResponder handles the response to the FailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) FailoverAllowDataLossResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database replication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to get the link for. +// linkID - the replication link ID to be retrieved. +func (client ReplicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "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.ReplicationLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/replicationLinks/{linkId}", 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 ReplicationLinksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) GetResponder(resp *http.Response) (result ReplicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists a database's replication links. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to retrieve links for. +func (client ReplicationLinksClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ReplicationLinksClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/replicationLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) ListByDatabaseResponder(resp *http.Response) (result ReplicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Unlink deletes a database replication link in forced or friendly way. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +// parameters - the required parameters for unlinking replication link. +func (client ReplicationLinksClient) Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (result ReplicationLinksUnlinkFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Unlink") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UnlinkPreparer(ctx, resourceGroupName, serverName, databaseName, linkID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", nil, "Failure preparing request") + return + } + + result, err = client.UnlinkSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", result.Response(), "Failure sending request") + return + } + + return +} + +// UnlinkPreparer prepares the Unlink request. +func (client ReplicationLinksClient) UnlinkPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UnlinkSender sends the Unlink request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) UnlinkSender(req *http.Request) (future ReplicationLinksUnlinkFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UnlinkResponder handles the response to the Unlink request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) UnlinkResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/restorabledroppeddatabases.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorabledroppeddatabases.go new file mode 100644 index 000000000000..7298ef0b736f --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorabledroppeddatabases.go @@ -0,0 +1,191 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RestorableDroppedDatabasesClient 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 RestorableDroppedDatabasesClient struct { + BaseClient +} + +// NewRestorableDroppedDatabasesClient creates an instance of the RestorableDroppedDatabasesClient client. +func NewRestorableDroppedDatabasesClient(subscriptionID string) RestorableDroppedDatabasesClient { + return NewRestorableDroppedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDroppedDatabasesClientWithBaseURI creates an instance of the RestorableDroppedDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableDroppedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedDatabasesClient { + return RestorableDroppedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a deleted database that can be restored +// Parameters: +// resourceGroupName - 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 - the name of the server. +// restorableDroppededDatabaseID - the id of the deleted database in the form of +// databaseName,deletionTimeInFileTimeFormat +func (client RestorableDroppedDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppededDatabaseID string) (result RestorableDroppedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, restorableDroppededDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "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.RestorableDroppedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorableDroppedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, restorableDroppededDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppededDatabaseId": autorest.Encode("path", restorableDroppededDatabaseID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/restorableDroppedDatabases/{restorableDroppededDatabaseId}", 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 RestorableDroppedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of deleted databases that can be restored +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client RestorableDroppedDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RestorableDroppedDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RestorableDroppedDatabasesClient) 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 = "2014-04-01" + 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}/restorableDroppedDatabases", 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 RestorableDroppedDatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) ListByServerResponder(resp *http.Response) (result RestorableDroppedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/restorepoints.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorepoints.go new file mode 100644 index 000000000000..38a54b5ca621 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorepoints.go @@ -0,0 +1,112 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RestorePointsClient 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 RestorePointsClient struct { + BaseClient +} + +// NewRestorePointsClient creates an instance of the RestorePointsClient client. +func NewRestorePointsClient(subscriptionID string) RestorePointsClient { + return NewRestorePointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorePointsClientWithBaseURI creates an instance of the RestorePointsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRestorePointsClientWithBaseURI(baseURI string, subscriptionID string) RestorePointsClient { + return RestorePointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase gets a list of database restore points. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to get available restore points. +func (client RestorePointsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RestorePointListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client RestorePointsClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/restorePoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client RestorePointsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) ListByDatabaseResponder(resp *http.Response) (result RestorePointListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/serverazureadadministrators.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverazureadadministrators.go new file mode 100644 index 000000000000..0be847c6534e --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverazureadadministrators.go @@ -0,0 +1,367 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAzureADAdministratorsClient 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 ServerAzureADAdministratorsClient struct { + BaseClient +} + +// NewServerAzureADAdministratorsClient creates an instance of the ServerAzureADAdministratorsClient client. +func NewServerAzureADAdministratorsClient(subscriptionID string) ServerAzureADAdministratorsClient { + return NewServerAzureADAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAzureADAdministratorsClientWithBaseURI creates an instance of the ServerAzureADAdministratorsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerAzureADAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ServerAzureADAdministratorsClient { + return ServerAzureADAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Server Active Directory Administrator or updates an existing server Active Directory +// Administrator. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// properties - the required parameters for creating or updating an Active Directory Administrator. +func (client ServerAzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, properties ServerAzureADAdministrator) (result ServerAzureADAdministratorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.ServerAdministratorProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.ServerAdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "properties.ServerAdministratorProperties.Login", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "properties.ServerAdministratorProperties.Sid", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "properties.ServerAdministratorProperties.TenantID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerAzureADAdministratorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, properties ServerAzureADAdministrator) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "activeDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", pathParameters), + autorest.WithJSON(properties), + 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 ServerAzureADAdministratorsClient) CreateOrUpdateSender(req *http.Request) (future ServerAzureADAdministratorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory Administrator. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministratorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerAzureADAdministratorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "activeDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/administrators/{administratorName}", 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 ServerAzureADAdministratorsClient) DeleteSender(req *http.Request) (future ServerAzureADAdministratorsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) DeleteResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns an server Administrator. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministrator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "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.ServerAzureADAdministratorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAzureADAdministratorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "activeDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/administrators/{administratorName}", 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 ServerAzureADAdministratorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) GetResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of server Administrators. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADAdministratorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerAdministratorListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAzureADAdministratorsClient) 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 = "2014-04-01" + 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}/administrators", 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 ServerAzureADAdministratorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) ListByServerResponder(resp *http.Response) (result ServerAdministratorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/servercommunicationlinks.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/servercommunicationlinks.go new file mode 100644 index 000000000000..cb24bd7204fc --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/servercommunicationlinks.go @@ -0,0 +1,363 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerCommunicationLinksClient 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 ServerCommunicationLinksClient struct { + BaseClient +} + +// NewServerCommunicationLinksClient creates an instance of the ServerCommunicationLinksClient client. +func NewServerCommunicationLinksClient(subscriptionID string) ServerCommunicationLinksClient { + return NewServerCommunicationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerCommunicationLinksClientWithBaseURI creates an instance of the ServerCommunicationLinksClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerCommunicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServerCommunicationLinksClient { + return ServerCommunicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a server communication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// communicationLinkName - the name of the server communication link. +// parameters - the required parameters for creating a server communication link. +func (client ServerCommunicationLinksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters ServerCommunicationLink) (result ServerCommunicationLinksCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerCommunicationLinkProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerCommunicationLinkProperties.PartnerServer", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerCommunicationLinksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, communicationLinkName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerCommunicationLinksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters ServerCommunicationLink) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", 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 ServerCommunicationLinksClient) CreateOrUpdateSender(req *http.Request) (future ServerCommunicationLinksCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) CreateOrUpdateResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server communication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// communicationLinkName - the name of the server communication link. +func (client ServerCommunicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, communicationLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerCommunicationLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/communicationLinks/{communicationLinkName}", 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 ServerCommunicationLinksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a server communication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// communicationLinkName - the name of the server communication link. +func (client ServerCommunicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result ServerCommunicationLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, communicationLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "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.ServerCommunicationLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerCommunicationLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/communicationLinks/{communicationLinkName}", 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 ServerCommunicationLinksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) GetResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server communication links. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerCommunicationLinksClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerCommunicationLinkListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerCommunicationLinksClient) 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 = "2014-04-01" + 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}/communicationLinks", 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 ServerCommunicationLinksClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) ListByServerResponder(resp *http.Response) (result ServerCommunicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/serverconnectionpolicies.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverconnectionpolicies.go new file mode 100644 index 000000000000..fd714db39b75 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverconnectionpolicies.go @@ -0,0 +1,195 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerConnectionPoliciesClient 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 ServerConnectionPoliciesClient struct { + BaseClient +} + +// NewServerConnectionPoliciesClient creates an instance of the ServerConnectionPoliciesClient client. +func NewServerConnectionPoliciesClient(subscriptionID string) ServerConnectionPoliciesClient { + return NewServerConnectionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerConnectionPoliciesClientWithBaseURI creates an instance of the ServerConnectionPoliciesClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerConnectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerConnectionPoliciesClient { + return ServerConnectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's connection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the required parameters for updating a secure connection policy. +func (client ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (result ServerConnectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "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.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerConnectionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", 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 ServerConnectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the server's secure connection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerConnectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "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.ServerConnectionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerConnectionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/connectionPolicies/{connectionPolicyName}", 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 ServerConnectionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) GetResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/serverkeys.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverkeys.go new file mode 100644 index 000000000000..54c560060bb9 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverkeys.go @@ -0,0 +1,401 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerKeysClient 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 ServerKeysClient struct { + BaseClient +} + +// NewServerKeysClient creates an instance of the ServerKeysClient client. +func NewServerKeysClient(subscriptionID string) ServerKeysClient { + return NewServerKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerKeysClientWithBaseURI creates an instance of the ServerKeysClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerKeysClientWithBaseURI(baseURI string, subscriptionID string) ServerKeysClient { + return ServerKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server key. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// keyName - the name of the server key to be operated on (updated or created). The key name is required to be +// in the format of 'vault_key_version'. For example, if the keyId is +// https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901, then the server key +// name should be formatted as: YourVaultName_YourKeyName_01234567890123456789012345678901 +// parameters - the requested server key resource state. +func (client ServerKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters ServerKey) (result ServerKeysCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerKeysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters ServerKey) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "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, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", 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 ServerKeysClient) CreateOrUpdateSender(req *http.Request) (future ServerKeysCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server key with the given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// keyName - the name of the server key to be deleted. +func (client ServerKeysClient) Delete(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result ServerKeysDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "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.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", 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 ServerKeysClient) DeleteSender(req *http.Request) (future ServerKeysDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server key. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// keyName - the name of the server key to be retrieved. +func (client ServerKeysClient) Get(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result ServerKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "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.ServerKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "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}/keys/{keyName}", 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 ServerKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) GetResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server keys. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerKeysClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.ListByServer") + defer func() { + sc := -1 + if result.sklr.Response.Response != nil { + sc = result.sklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sklr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sklr.hasNextLink() && result.sklr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerKeysClient) 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 = "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}/keys", 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 ServerKeysClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) ListByServerResponder(resp *http.Response) (result ServerKeyListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerKeysClient) listByServerNextResults(ctx context.Context, lastResults ServerKeyListResult) (result ServerKeyListResult, err error) { + req, err := lastResults.serverKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerKeysClient", "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.ServerKeysClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerKeysClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/servers.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/servers.go new file mode 100644 index 000000000000..84bd7821606a --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/servers.go @@ -0,0 +1,669 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServersClient 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 ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability determines whether a resource can be created with the specified name. +// Parameters: +// parameters - the parameters to request for name availability. +func (client ServersClient) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequest) (result CheckNameAvailabilityResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ServersClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServersClient) CheckNameAvailabilityPreparer(ctx context.Context, parameters CheckNameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServersClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested server resource state. +func (client ServersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (*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 = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", 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 ServersClient) CreateOrUpdateSender(req *http.Request) (future ServersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateOrUpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServersClient) DeletePreparer(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 = "2015-05-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}", 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 ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "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.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) 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 = "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}", 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 ServersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all servers in the subscription. +func (client ServersClient) List(ctx context.Context) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "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}/providers/Microsoft.Sql/servers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServersClient) ListResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListComplete(ctx context.Context) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of servers in a resource groups. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested server resource state. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (result ServersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (*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 = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", 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 ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/serverusages.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverusages.go new file mode 100644 index 000000000000..662861e4c6cf --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverusages.go @@ -0,0 +1,110 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerUsagesClient 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 ServerUsagesClient struct { + BaseClient +} + +// NewServerUsagesClient creates an instance of the ServerUsagesClient client. +func NewServerUsagesClient(subscriptionID string) ServerUsagesClient { + return NewServerUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerUsagesClientWithBaseURI creates an instance of the ServerUsagesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerUsagesClientWithBaseURI(baseURI string, subscriptionID string) ServerUsagesClient { + return ServerUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer returns server usages. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerUsagesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerUsageListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerUsagesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerUsagesClient) 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 = "2014-04-01" + 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}/usages", 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 ServerUsagesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerUsagesClient) ListByServerResponder(resp *http.Response) (result ServerUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/serviceobjectives.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/serviceobjectives.go new file mode 100644 index 000000000000..0b21dd5344f9 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serviceobjectives.go @@ -0,0 +1,190 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServiceObjectivesClient 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 ServiceObjectivesClient struct { + BaseClient +} + +// NewServiceObjectivesClient creates an instance of the ServiceObjectivesClient client. +func NewServiceObjectivesClient(subscriptionID string) ServiceObjectivesClient { + return NewServiceObjectivesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceObjectivesClientWithBaseURI creates an instance of the ServiceObjectivesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceObjectivesClientWithBaseURI(baseURI string, subscriptionID string) ServiceObjectivesClient { + return ServiceObjectivesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database service objective. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// serviceObjectiveName - the name of the service objective to retrieve. +func (client ServiceObjectivesClient) Get(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (result ServiceObjective, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceObjectivesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, serviceObjectiveName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "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.ServiceObjectivesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceObjectivesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "serviceObjectiveName": autorest.Encode("path", serviceObjectiveName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/serviceObjectives/{serviceObjectiveName}", 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 ServiceObjectivesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) GetResponder(resp *http.Response) (result ServiceObjective, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns database service objectives. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServiceObjectivesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServiceObjectiveListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceObjectivesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServiceObjectivesClient) 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 = "2014-04-01" + 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}/serviceObjectives", 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 ServiceObjectivesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) ListByServerResponder(resp *http.Response) (result ServiceObjectiveListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/servicetieradvisors.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/servicetieradvisors.go new file mode 100644 index 000000000000..7886aa585995 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/servicetieradvisors.go @@ -0,0 +1,194 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServiceTierAdvisorsClient 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 ServiceTierAdvisorsClient struct { + BaseClient +} + +// NewServiceTierAdvisorsClient creates an instance of the ServiceTierAdvisorsClient client. +func NewServiceTierAdvisorsClient(subscriptionID string) ServiceTierAdvisorsClient { + return NewServiceTierAdvisorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceTierAdvisorsClientWithBaseURI creates an instance of the ServiceTierAdvisorsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceTierAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) ServiceTierAdvisorsClient { + return ServiceTierAdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a service tier advisor. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of database. +// serviceTierAdvisorName - the name of service tier advisor. +func (client ServiceTierAdvisorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (result ServiceTierAdvisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceTierAdvisorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, serviceTierAdvisorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "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.ServiceTierAdvisorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceTierAdvisorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "serviceTierAdvisorName": autorest.Encode("path", serviceTierAdvisorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/serviceTierAdvisors/{serviceTierAdvisorName}", 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 ServiceTierAdvisorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceTierAdvisorsClient) GetResponder(resp *http.Response) (result ServiceTierAdvisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns service tier advisors for specified database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of database. +func (client ServiceTierAdvisorsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ServiceTierAdvisorListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceTierAdvisorsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ServiceTierAdvisorsClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/serviceTierAdvisors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceTierAdvisorsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ServiceTierAdvisorsClient) ListByDatabaseResponder(resp *http.Response) (result ServiceTierAdvisorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/sqlapi/interfaces.go new file mode 100644 index 000000000000..4b93a0531a0f --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/sqlapi/interfaces.go @@ -0,0 +1,386 @@ +package sqlapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql" + "github.com/Azure/go-autorest/autorest" +) + +// RecoverableDatabasesClientAPI contains the set of methods on the RecoverableDatabasesClient type. +type RecoverableDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RecoverableDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RecoverableDatabaseListResult, err error) +} + +var _ RecoverableDatabasesClientAPI = (*sql.RecoverableDatabasesClient)(nil) + +// RestorableDroppedDatabasesClientAPI contains the set of methods on the RestorableDroppedDatabasesClient type. +type RestorableDroppedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppededDatabaseID string) (result sql.RestorableDroppedDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResult, err error) +} + +var _ RestorableDroppedDatabasesClientAPI = (*sql.RestorableDroppedDatabasesClient)(nil) + +// RestorePointsClientAPI contains the set of methods on the RestorePointsClient type. +type RestorePointsClientAPI interface { + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RestorePointListResult, err error) +} + +var _ RestorePointsClientAPI = (*sql.RestorePointsClient)(nil) + +// ServersClientAPI contains the set of methods on the ServersClient type. +type ServersClientAPI interface { + CheckNameAvailability(ctx context.Context, parameters sql.CheckNameAvailabilityRequest) (result sql.CheckNameAvailabilityResponse, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.Server) (result sql.ServersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.Server, err error) + List(ctx context.Context) (result sql.ServerListResultPage, err error) + ListComplete(ctx context.Context) (result sql.ServerListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.ServerListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.ServerListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerUpdate) (result sql.ServersUpdateFuture, err error) +} + +var _ ServersClientAPI = (*sql.ServersClient)(nil) + +// ServerConnectionPoliciesClientAPI contains the set of methods on the ServerConnectionPoliciesClient type. +type ServerConnectionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerConnectionPolicy) (result sql.ServerConnectionPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicy, err error) +} + +var _ ServerConnectionPoliciesClientAPI = (*sql.ServerConnectionPoliciesClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + CreateImportOperation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ImportExtensionRequest) (result sql.DatabasesCreateImportOperationFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.Database) (result sql.DatabasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) + Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExportRequest) (result sql.DatabasesExportFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, expand string) (result sql.Database, err error) + GetByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, databaseName string) (result sql.Database, err error) + GetByRecommendedElasticPool(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string, databaseName string) (result sql.Database, err error) + Import(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ImportRequest) (result sql.DatabasesImportFuture, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResult, err error) + ListByRecommendedElasticPool(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (result sql.DatabaseListResult, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, expand string, filter string) (result sql.DatabaseListResult, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.MetricDefinitionListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.MetricListResult, err error) + Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesPauseFuture, err error) + Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesResumeFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseUpdate) (result sql.DatabasesUpdateFuture, err error) +} + +var _ DatabasesClientAPI = (*sql.DatabasesClient)(nil) + +// DatabaseThreatDetectionPoliciesClientAPI contains the set of methods on the DatabaseThreatDetectionPoliciesClient type. +type DatabaseThreatDetectionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseSecurityAlertPolicy) (result sql.DatabaseSecurityAlertPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseSecurityAlertPolicy, err error) +} + +var _ DatabaseThreatDetectionPoliciesClientAPI = (*sql.DatabaseThreatDetectionPoliciesClient)(nil) + +// DataMaskingPoliciesClientAPI contains the set of methods on the DataMaskingPoliciesClient type. +type DataMaskingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DataMaskingPolicy) (result sql.DataMaskingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataMaskingPolicy, err error) +} + +var _ DataMaskingPoliciesClientAPI = (*sql.DataMaskingPoliciesClient)(nil) + +// DataMaskingRulesClientAPI contains the set of methods on the DataMaskingRulesClient type. +type DataMaskingRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters sql.DataMaskingRule) (result sql.DataMaskingRule, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataMaskingRuleListResult, err error) +} + +var _ DataMaskingRulesClientAPI = (*sql.DataMaskingRulesClient)(nil) + +// ElasticPoolsClientAPI contains the set of methods on the ElasticPoolsClient type. +type ElasticPoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPool) (result sql.ElasticPoolsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPool, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ElasticPoolListResult, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.MetricDefinitionListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result sql.MetricListResult, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPoolUpdate) (result sql.ElasticPoolsUpdateFuture, err error) +} + +var _ ElasticPoolsClientAPI = (*sql.ElasticPoolsClient)(nil) + +// FirewallRulesClientAPI contains the set of methods on the FirewallRulesClient type. +type FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters sql.FirewallRule) (result sql.FirewallRule, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result sql.FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.FirewallRuleListResult, err error) +} + +var _ FirewallRulesClientAPI = (*sql.FirewallRulesClient)(nil) + +// GeoBackupPoliciesClientAPI contains the set of methods on the GeoBackupPoliciesClient type. +type GeoBackupPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.GeoBackupPolicy) (result sql.GeoBackupPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.GeoBackupPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.GeoBackupPolicyListResult, err error) +} + +var _ GeoBackupPoliciesClientAPI = (*sql.GeoBackupPoliciesClient)(nil) + +// ReplicationLinksClientAPI contains the set of methods on the ReplicationLinksClient type. +type ReplicationLinksClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverFuture, err error) + FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLink, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResult, err error) + Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters sql.UnlinkParameters) (result sql.ReplicationLinksUnlinkFuture, err error) +} + +var _ ReplicationLinksClientAPI = (*sql.ReplicationLinksClient)(nil) + +// ServerAzureADAdministratorsClientAPI contains the set of methods on the ServerAzureADAdministratorsClient type. +type ServerAzureADAdministratorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, properties sql.ServerAzureADAdministrator) (result sql.ServerAzureADAdministratorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADAdministratorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADAdministrator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAdministratorListResult, err error) +} + +var _ ServerAzureADAdministratorsClientAPI = (*sql.ServerAzureADAdministratorsClient)(nil) + +// ServerCommunicationLinksClientAPI contains the set of methods on the ServerCommunicationLinksClient type. +type ServerCommunicationLinksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters sql.ServerCommunicationLink) (result sql.ServerCommunicationLinksCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result sql.ServerCommunicationLink, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerCommunicationLinkListResult, err error) +} + +var _ ServerCommunicationLinksClientAPI = (*sql.ServerCommunicationLinksClient)(nil) + +// ServiceObjectivesClientAPI contains the set of methods on the ServiceObjectivesClient type. +type ServiceObjectivesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (result sql.ServiceObjective, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServiceObjectiveListResult, err error) +} + +var _ ServiceObjectivesClientAPI = (*sql.ServiceObjectivesClient)(nil) + +// ElasticPoolActivitiesClientAPI contains the set of methods on the ElasticPoolActivitiesClient type. +type ElasticPoolActivitiesClientAPI interface { + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolActivityListResult, err error) +} + +var _ ElasticPoolActivitiesClientAPI = (*sql.ElasticPoolActivitiesClient)(nil) + +// ElasticPoolDatabaseActivitiesClientAPI contains the set of methods on the ElasticPoolDatabaseActivitiesClient type. +type ElasticPoolDatabaseActivitiesClientAPI interface { + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolDatabaseActivityListResult, err error) +} + +var _ ElasticPoolDatabaseActivitiesClientAPI = (*sql.ElasticPoolDatabaseActivitiesClient)(nil) + +// ServiceTierAdvisorsClientAPI contains the set of methods on the ServiceTierAdvisorsClient type. +type ServiceTierAdvisorsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (result sql.ServiceTierAdvisor, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ServiceTierAdvisorListResult, err error) +} + +var _ ServiceTierAdvisorsClientAPI = (*sql.ServiceTierAdvisorsClient)(nil) + +// TransparentDataEncryptionsClientAPI contains the set of methods on the TransparentDataEncryptionsClient type. +type TransparentDataEncryptionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.TransparentDataEncryption) (result sql.TransparentDataEncryption, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryption, err error) +} + +var _ TransparentDataEncryptionsClientAPI = (*sql.TransparentDataEncryptionsClient)(nil) + +// TransparentDataEncryptionActivitiesClientAPI contains the set of methods on the TransparentDataEncryptionActivitiesClient type. +type TransparentDataEncryptionActivitiesClientAPI interface { + ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryptionActivityListResult, err error) +} + +var _ TransparentDataEncryptionActivitiesClientAPI = (*sql.TransparentDataEncryptionActivitiesClient)(nil) + +// ServerUsagesClientAPI contains the set of methods on the ServerUsagesClient type. +type ServerUsagesClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerUsageListResult, err error) +} + +var _ ServerUsagesClientAPI = (*sql.ServerUsagesClient)(nil) + +// DatabaseUsagesClientAPI contains the set of methods on the DatabaseUsagesClient type. +type DatabaseUsagesClientAPI interface { + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseUsageListResult, err error) +} + +var _ DatabaseUsagesClientAPI = (*sql.DatabaseUsagesClient)(nil) + +// CapabilitiesClientAPI contains the set of methods on the CapabilitiesClient type. +type CapabilitiesClientAPI interface { + ListByLocation(ctx context.Context, locationName string) (result sql.LocationCapabilities, err error) +} + +var _ CapabilitiesClientAPI = (*sql.CapabilitiesClient)(nil) + +// DatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the DatabaseBlobAuditingPoliciesClient type. +type DatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseBlobAuditingPolicy) (result sql.DatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ DatabaseBlobAuditingPoliciesClientAPI = (*sql.DatabaseBlobAuditingPoliciesClient)(nil) + +// EncryptionProtectorsClientAPI contains the set of methods on the EncryptionProtectorsClient type. +type EncryptionProtectorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.EncryptionProtector) (result sql.EncryptionProtectorsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtector, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorListResultIterator, err error) + Revalidate(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorsRevalidateFuture, err error) +} + +var _ EncryptionProtectorsClientAPI = (*sql.EncryptionProtectorsClient)(nil) + +// FailoverGroupsClientAPI contains the set of methods on the FailoverGroupsClient type. +type FailoverGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters sql.FailoverGroup) (result sql.FailoverGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsFailoverFuture, err error) + ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsForceFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroup, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.FailoverGroupListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.FailoverGroupListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters sql.FailoverGroupUpdate) (result sql.FailoverGroupsUpdateFuture, err error) +} + +var _ FailoverGroupsClientAPI = (*sql.FailoverGroupsClient)(nil) + +// ManagedInstancesClientAPI contains the set of methods on the ManagedInstancesClient type. +type ManagedInstancesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstance) (result sql.ManagedInstancesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstance, err error) + List(ctx context.Context) (result sql.ManagedInstanceListResultPage, err error) + ListComplete(ctx context.Context) (result sql.ManagedInstanceListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.ManagedInstanceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.ManagedInstanceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceUpdate) (result sql.ManagedInstancesUpdateFuture, err error) +} + +var _ ManagedInstancesClientAPI = (*sql.ManagedInstancesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result sql.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result sql.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*sql.OperationsClient)(nil) + +// ServerKeysClientAPI contains the set of methods on the ServerKeysClient type. +type ServerKeysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters sql.ServerKey) (result sql.ServerKeysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result sql.ServerKeysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result sql.ServerKey, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerKeyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerKeyListResultIterator, err error) +} + +var _ ServerKeysClientAPI = (*sql.ServerKeysClient)(nil) + +// SyncAgentsClientAPI contains the set of methods on the SyncAgentsClient type. +type SyncAgentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters sql.SyncAgent) (result sql.SyncAgentsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentsDeleteFuture, err error) + GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentKeyProperties, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgent, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.SyncAgentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.SyncAgentListResultIterator, err error) + ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentLinkedDatabaseListResultPage, err error) + ListLinkedDatabasesComplete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentLinkedDatabaseListResultIterator, err error) +} + +var _ SyncAgentsClientAPI = (*sql.SyncAgentsClient)(nil) + +// SyncGroupsClientAPI contains the set of methods on the SyncGroupsClient type. +type SyncGroupsClientAPI interface { + CancelSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters sql.SyncGroup) (result sql.SyncGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroup, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultIterator, err error) + ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) + ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) + ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultPage, err error) + ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultIterator, err error) + ListSyncDatabaseIds(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultPage, err error) + ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultIterator, err error) + RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsRefreshHubSchemaFuture, err error) + TriggerSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters sql.SyncGroup) (result sql.SyncGroupsUpdateFuture, err error) +} + +var _ SyncGroupsClientAPI = (*sql.SyncGroupsClient)(nil) + +// SyncMembersClientAPI contains the set of methods on the SyncMembersClient type. +type SyncMembersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters sql.SyncMember) (result sql.SyncMembersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMembersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMember, err error) + ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncMemberListResultPage, err error) + ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncMemberListResultIterator, err error) + ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) + ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) + RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMembersRefreshMemberSchemaFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters sql.SyncMember) (result sql.SyncMembersUpdateFuture, err error) +} + +var _ SyncMembersClientAPI = (*sql.SyncMembersClient)(nil) + +// SubscriptionUsagesClientAPI contains the set of methods on the SubscriptionUsagesClient type. +type SubscriptionUsagesClientAPI interface { + Get(ctx context.Context, locationName string, usageName string) (result sql.SubscriptionUsage, err error) + ListByLocation(ctx context.Context, locationName string) (result sql.SubscriptionUsageListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string) (result sql.SubscriptionUsageListResultIterator, err error) +} + +var _ SubscriptionUsagesClientAPI = (*sql.SubscriptionUsagesClient)(nil) + +// VirtualClustersClientAPI contains the set of methods on the VirtualClustersClient type. +type VirtualClustersClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.VirtualClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.VirtualCluster, err error) + List(ctx context.Context) (result sql.VirtualClusterListResultPage, err error) + ListComplete(ctx context.Context) (result sql.VirtualClusterListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.VirtualClusterListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.VirtualClusterListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters sql.VirtualClusterUpdate) (result sql.VirtualClustersUpdateFuture, err error) +} + +var _ VirtualClustersClientAPI = (*sql.VirtualClustersClient)(nil) + +// VirtualNetworkRulesClientAPI contains the set of methods on the VirtualNetworkRulesClient type. +type VirtualNetworkRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters sql.VirtualNetworkRule) (result sql.VirtualNetworkRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result sql.VirtualNetworkRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result sql.VirtualNetworkRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.VirtualNetworkRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.VirtualNetworkRuleListResultIterator, err error) +} + +var _ VirtualNetworkRulesClientAPI = (*sql.VirtualNetworkRulesClient)(nil) diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/subscriptionusages.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/subscriptionusages.go new file mode 100644 index 000000000000..2362a090b572 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/subscriptionusages.go @@ -0,0 +1,226 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SubscriptionUsagesClient 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 SubscriptionUsagesClient struct { + BaseClient +} + +// NewSubscriptionUsagesClient creates an instance of the SubscriptionUsagesClient client. +func NewSubscriptionUsagesClient(subscriptionID string) SubscriptionUsagesClient { + return NewSubscriptionUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionUsagesClientWithBaseURI creates an instance of the SubscriptionUsagesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSubscriptionUsagesClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionUsagesClient { + return SubscriptionUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a subscription usage metric. +// Parameters: +// locationName - the name of the region where the resource is located. +// usageName - name of usage metric to return. +func (client SubscriptionUsagesClient) Get(ctx context.Context, locationName string, usageName string) (result SubscriptionUsage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, usageName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "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.SubscriptionUsagesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubscriptionUsagesClient) GetPreparer(ctx context.Context, locationName string, usageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "usageName": autorest.Encode("path", usageName), + } + + 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}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}", 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 SubscriptionUsagesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) GetResponder(resp *http.Response) (result SubscriptionUsage, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation gets all subscription usage metrics in a given location. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client SubscriptionUsagesClient) ListByLocation(ctx context.Context, locationName string) (result SubscriptionUsageListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.ListByLocation") + defer func() { + sc := -1 + if result.sulr.Response.Response != nil { + sc = result.sulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.sulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.sulr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.sulr.hasNextLink() && result.sulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client SubscriptionUsagesClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "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}/providers/Microsoft.Sql/locations/{locationName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionUsagesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) ListByLocationResponder(resp *http.Response) (result SubscriptionUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client SubscriptionUsagesClient) listByLocationNextResults(ctx context.Context, lastResults SubscriptionUsageListResult) (result SubscriptionUsageListResult, err error) { + req, err := lastResults.subscriptionUsageListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionUsagesClient) ListByLocationComplete(ctx context.Context, locationName string) (result SubscriptionUsageListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName) + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/syncagents.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncagents.go new file mode 100644 index 000000000000..9ad3b1b33350 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncagents.go @@ -0,0 +1,597 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SyncAgentsClient 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 SyncAgentsClient struct { + BaseClient +} + +// NewSyncAgentsClient creates an instance of the SyncAgentsClient client. +func NewSyncAgentsClient(subscriptionID string) SyncAgentsClient { + return NewSyncAgentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncAgentsClientWithBaseURI creates an instance of the SyncAgentsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncAgentsClientWithBaseURI(baseURI string, subscriptionID string) SyncAgentsClient { + return SyncAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +// parameters - the requested sync agent resource state. +func (client SyncAgentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters SyncAgent) (result SyncAgentsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, syncAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SyncAgentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters SyncAgent) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", 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 SyncAgentsClient) CreateOrUpdateSender(req *http.Request) (future SyncAgentsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncAgentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2015-05-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}/syncAgents/{syncAgentName}", 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 SyncAgentsClient) DeleteSender(req *http.Request) (future SyncAgentsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateKey generates a sync agent key. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentKeyProperties, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.GenerateKey") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateKeyPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", resp, "Failure sending request") + return + } + + result, err = client.GenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", resp, "Failure responding to request") + return + } + + return +} + +// GenerateKeyPreparer prepares the GenerateKey request. +func (client SyncAgentsClient) GenerateKeyPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2015-05-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}/syncAgents/{syncAgentName}/generateKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateKeySender sends the GenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) GenerateKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateKeyResponder handles the response to the GenerateKey request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GenerateKeyResponder(resp *http.Response) (result SyncAgentKeyProperties, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "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.SyncAgentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncAgentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + 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}/syncAgents/{syncAgentName}", 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 SyncAgentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GetResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists sync agents in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +func (client SyncAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.salr.Response.Response != nil { + sc = result.salr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.salr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.salr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.salr.hasNextLink() && result.salr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client SyncAgentsClient) 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 = "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}/syncAgents", 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 SyncAgentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListByServerResponder(resp *http.Response) (result SyncAgentListResult, err error) { + err = autorest.Respond( + resp, + 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 SyncAgentsClient) listByServerNextResults(ctx context.Context, lastResults SyncAgentListResult) (result SyncAgentListResult, err error) { + req, err := lastResults.syncAgentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "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.SyncAgentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncAgentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// ListLinkedDatabases lists databases linked to a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListLinkedDatabases") + defer func() { + sc := -1 + if result.saldlr.Response.Response != nil { + sc = result.saldlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listLinkedDatabasesNextResults + req, err := client.ListLinkedDatabasesPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListLinkedDatabasesSender(req) + if err != nil { + result.saldlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", resp, "Failure sending request") + return + } + + result.saldlr, err = client.ListLinkedDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", resp, "Failure responding to request") + return + } + if result.saldlr.hasNextLink() && result.saldlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListLinkedDatabasesPreparer prepares the ListLinkedDatabases request. +func (client SyncAgentsClient) ListLinkedDatabasesPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + 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}/syncAgents/{syncAgentName}/linkedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLinkedDatabasesSender sends the ListLinkedDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) ListLinkedDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListLinkedDatabasesResponder handles the response to the ListLinkedDatabases request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListLinkedDatabasesResponder(resp *http.Response) (result SyncAgentLinkedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listLinkedDatabasesNextResults retrieves the next set of results, if any. +func (client SyncAgentsClient) listLinkedDatabasesNextResults(ctx context.Context, lastResults SyncAgentLinkedDatabaseListResult) (result SyncAgentLinkedDatabaseListResult, err error) { + req, err := lastResults.syncAgentLinkedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListLinkedDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", resp, "Failure sending next results request") + } + result, err = client.ListLinkedDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListLinkedDatabasesComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncAgentsClient) ListLinkedDatabasesComplete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListLinkedDatabases") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListLinkedDatabases(ctx, resourceGroupName, serverName, syncAgentName) + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/syncgroups.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncgroups.go new file mode 100644 index 000000000000..6d7db3c8d547 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncgroups.go @@ -0,0 +1,1107 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SyncGroupsClient 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 SyncGroupsClient struct { + BaseClient +} + +// NewSyncGroupsClient creates an instance of the SyncGroupsClient client. +func NewSyncGroupsClient(subscriptionID string) SyncGroupsClient { + return NewSyncGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncGroupsClientWithBaseURI creates an instance of the SyncGroupsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient { + return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CancelSync cancels a sync group synchronization. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) CancelSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.CancelSync") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelSyncPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSyncSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure sending request") + return + } + + result, err = client.CancelSyncResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure responding to request") + return + } + + return +} + +// CancelSyncPreparer prepares the CancelSync request. +func (client SyncGroupsClient) CancelSyncPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSyncSender sends the CancelSync request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) CancelSyncSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelSyncResponder handles the response to the CancelSync request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CancelSyncResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// parameters - the requested sync group resource state. +func (client SyncGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (result SyncGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SyncGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) CreateOrUpdateSender(req *http.Request) (future SyncGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) DeleteSender(req *http.Request) (future SyncGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "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.SyncGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + 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}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) GetResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists sync groups under a hub database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +func (client SyncGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.sglr.Response.Response != nil { + sc = result.sglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.sglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.sglr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.sglr.hasNextLink() && result.sglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client SyncGroupsClient) ListByDatabasePreparer(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}/syncGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListByDatabaseResponder(resp *http.Response) (result SyncGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listByDatabaseNextResults(ctx context.Context, lastResults SyncGroupListResult) (result SyncGroupListResult, err error) { + req, err := lastResults.syncGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// ListHubSchemas gets a collection of hub database schemas. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListHubSchemas") + defer func() { + sc := -1 + if result.sfsplr.Response.Response != nil { + sc = result.sfsplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listHubSchemasNextResults + req, err := client.ListHubSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", nil, "Failure preparing request") + return + } + + resp, err := client.ListHubSchemasSender(req) + if err != nil { + result.sfsplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure sending request") + return + } + + result.sfsplr, err = client.ListHubSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure responding to request") + return + } + if result.sfsplr.hasNextLink() && result.sfsplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListHubSchemasPreparer prepares the ListHubSchemas request. +func (client SyncGroupsClient) ListHubSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + 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}/syncGroups/{syncGroupName}/hubSchemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListHubSchemasSender sends the ListHubSchemas request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListHubSchemasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListHubSchemasResponder handles the response to the ListHubSchemas request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListHubSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listHubSchemasNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listHubSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListHubSchemasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", resp, "Failure sending next results request") + } + result, err = client.ListHubSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListHubSchemasComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListHubSchemas") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListHubSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListLogs gets a collection of sync group logs. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// startTime - get logs generated after this time. +// endTime - get logs generated before this time. +// typeParameter - the types of logs to retrieve. +// continuationToken - the continuation token for this operation. +func (client SyncGroupsClient) ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") + defer func() { + sc := -1 + if result.sgllr.Response.Response != nil { + sc = result.sgllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listLogsNextResults + req, err := client.ListLogsPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", nil, "Failure preparing request") + return + } + + resp, err := client.ListLogsSender(req) + if err != nil { + result.sgllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure sending request") + return + } + + result.sgllr, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure responding to request") + return + } + if result.sgllr.hasNextLink() && result.sgllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListLogsPreparer prepares the ListLogs request. +func (client SyncGroupsClient) ListLogsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "endTime": autorest.Encode("query", endTime), + "startTime": autorest.Encode("query", startTime), + "type": autorest.Encode("query", typeParameter), + } + if len(continuationToken) > 0 { + queryParameters["continuationToken"] = autorest.Encode("query", continuationToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLogsSender sends the ListLogs request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListLogsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListLogsResponder handles the response to the ListLogs request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListLogsResponder(resp *http.Response) (result SyncGroupLogListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listLogsNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listLogsNextResults(ctx context.Context, lastResults SyncGroupLogListResult) (result SyncGroupLogListResult, err error) { + req, err := lastResults.syncGroupLogListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListLogsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListLogsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListLogs(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + return +} + +// ListSyncDatabaseIds gets a collection of sync database ids. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client SyncGroupsClient) ListSyncDatabaseIds(ctx context.Context, locationName string) (result SyncDatabaseIDListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListSyncDatabaseIds") + defer func() { + sc := -1 + if result.sdilr.Response.Response != nil { + sc = result.sdilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listSyncDatabaseIdsNextResults + req, err := client.ListSyncDatabaseIdsPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", nil, "Failure preparing request") + return + } + + resp, err := client.ListSyncDatabaseIdsSender(req) + if err != nil { + result.sdilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure sending request") + return + } + + result.sdilr, err = client.ListSyncDatabaseIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure responding to request") + return + } + if result.sdilr.hasNextLink() && result.sdilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListSyncDatabaseIdsPreparer prepares the ListSyncDatabaseIds request. +func (client SyncGroupsClient) ListSyncDatabaseIdsPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "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}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSyncDatabaseIdsSender sends the ListSyncDatabaseIds request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListSyncDatabaseIdsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSyncDatabaseIdsResponder handles the response to the ListSyncDatabaseIds request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListSyncDatabaseIdsResponder(resp *http.Response) (result SyncDatabaseIDListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listSyncDatabaseIdsNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listSyncDatabaseIdsNextResults(ctx context.Context, lastResults SyncDatabaseIDListResult) (result SyncDatabaseIDListResult, err error) { + req, err := lastResults.syncDatabaseIDListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSyncDatabaseIdsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListSyncDatabaseIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListSyncDatabaseIdsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result SyncDatabaseIDListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListSyncDatabaseIds") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListSyncDatabaseIds(ctx, locationName) + return +} + +// RefreshHubSchema refreshes a hub database schema. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroupsRefreshHubSchemaFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.RefreshHubSchema") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RefreshHubSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", nil, "Failure preparing request") + return + } + + result, err = client.RefreshHubSchemaSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", result.Response(), "Failure sending request") + return + } + + return +} + +// RefreshHubSchemaPreparer prepares the RefreshHubSchema request. +func (client SyncGroupsClient) RefreshHubSchemaPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshHubSchemaSender sends the RefreshHubSchema request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) RefreshHubSchemaSender(req *http.Request) (future SyncGroupsRefreshHubSchemaFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshHubSchemaResponder handles the response to the RefreshHubSchema request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) RefreshHubSchemaResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// TriggerSync triggers a sync group synchronization. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) TriggerSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.TriggerSync") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TriggerSyncPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", nil, "Failure preparing request") + return + } + + resp, err := client.TriggerSyncSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure sending request") + return + } + + result, err = client.TriggerSyncResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure responding to request") + return + } + + return +} + +// TriggerSyncPreparer prepares the TriggerSync request. +func (client SyncGroupsClient) TriggerSyncPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TriggerSyncSender sends the TriggerSync request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) TriggerSyncSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// TriggerSyncResponder handles the response to the TriggerSync request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) TriggerSyncResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// parameters - the requested sync group resource state. +func (client SyncGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (result SyncGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SyncGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) UpdateSender(req *http.Request) (future SyncGroupsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) UpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/syncmembers.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncmembers.go new file mode 100644 index 000000000000..65bbe6fa921d --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncmembers.go @@ -0,0 +1,712 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SyncMembersClient 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 SyncMembersClient struct { + BaseClient +} + +// NewSyncMembersClient creates an instance of the SyncMembersClient client. +func NewSyncMembersClient(subscriptionID string) SyncMembersClient { + return NewSyncMembersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncMembersClientWithBaseURI creates an instance of the SyncMembersClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncMembersClientWithBaseURI(baseURI string, subscriptionID string) SyncMembersClient { + return SyncMembersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +// parameters - the requested sync member resource state. +func (client SyncMembersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SyncMembersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) CreateOrUpdateSender(req *http.Request) (future SyncMembersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) CreateOrUpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncMembersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) DeleteSender(req *http.Request) (future SyncMembersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMember, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "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.SyncMembersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncMembersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + 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}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) GetResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncGroup lists sync members in the given sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncMembersClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.smlr.Response.Response != nil { + sc = result.smlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySyncGroupNextResults + req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.smlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure sending request") + return + } + + result.smlr, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure responding to request") + return + } + if result.smlr.hasNextLink() && result.smlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySyncGroupPreparer prepares the ListBySyncGroup request. +func (client SyncMembersClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + 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}/syncGroups/{syncGroupName}/syncMembers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) ListBySyncGroupResponder(resp *http.Response) (result SyncMemberListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySyncGroupNextResults retrieves the next set of results, if any. +func (client SyncMembersClient) listBySyncGroupNextResults(ctx context.Context, lastResults SyncMemberListResult) (result SyncMemberListResult, err error) { + req, err := lastResults.syncMemberListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySyncGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncMembersClient) ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySyncGroup(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListMemberSchemas gets a sync member database schema. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas") + defer func() { + sc := -1 + if result.sfsplr.Response.Response != nil { + sc = result.sfsplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listMemberSchemasNextResults + req, err := client.ListMemberSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", nil, "Failure preparing request") + return + } + + resp, err := client.ListMemberSchemasSender(req) + if err != nil { + result.sfsplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure sending request") + return + } + + result.sfsplr, err = client.ListMemberSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure responding to request") + return + } + if result.sfsplr.hasNextLink() && result.sfsplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListMemberSchemasPreparer prepares the ListMemberSchemas request. +func (client SyncMembersClient) ListMemberSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + 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}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMemberSchemasSender sends the ListMemberSchemas request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) ListMemberSchemasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMemberSchemasResponder handles the response to the ListMemberSchemas request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) ListMemberSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listMemberSchemasNextResults retrieves the next set of results, if any. +func (client SyncMembersClient) listMemberSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListMemberSchemasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure sending next results request") + } + result, err = client.ListMemberSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListMemberSchemasComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncMembersClient) ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListMemberSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + return +} + +// RefreshMemberSchema refreshes a sync member database schema. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersRefreshMemberSchemaFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.RefreshMemberSchema") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RefreshMemberSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", nil, "Failure preparing request") + return + } + + result, err = client.RefreshMemberSchemaSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", result.Response(), "Failure sending request") + return + } + + return +} + +// RefreshMemberSchemaPreparer prepares the RefreshMemberSchema request. +func (client SyncMembersClient) RefreshMemberSchemaPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshMemberSchemaSender sends the RefreshMemberSchema request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) RefreshMemberSchemaSender(req *http.Request) (future SyncMembersRefreshMemberSchemaFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshMemberSchemaResponder handles the response to the RefreshMemberSchema request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) RefreshMemberSchemaResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +// parameters - the requested sync member resource state. +func (client SyncMembersClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SyncMembersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) UpdateSender(req *http.Request) (future SyncMembersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) UpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptionactivities.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptionactivities.go similarity index 100% rename from services/preview/sql/mgmt/v5.0/sql/transparentdataencryptionactivities.go rename to services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptionactivities.go diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptions.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptions.go new file mode 100644 index 000000000000..691b41cd1464 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptions.go @@ -0,0 +1,198 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// TransparentDataEncryptionsClient 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 TransparentDataEncryptionsClient struct { + BaseClient +} + +// NewTransparentDataEncryptionsClient creates an instance of the TransparentDataEncryptionsClient client. +func NewTransparentDataEncryptionsClient(subscriptionID string) TransparentDataEncryptionsClient { + return NewTransparentDataEncryptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransparentDataEncryptionsClientWithBaseURI creates an instance of the TransparentDataEncryptionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewTransparentDataEncryptionsClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionsClient { + return TransparentDataEncryptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which setting the transparent data encryption applies. +// parameters - the required parameters for creating or updating transparent data encryption. +func (client TransparentDataEncryptionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (result TransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "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.TransparentDataEncryptionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TransparentDataEncryptionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (*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), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}", 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 TransparentDataEncryptionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "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.TransparentDataEncryptionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TransparentDataEncryptionsClient) 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), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + 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}/transparentDataEncryption/{transparentDataEncryptionName}", 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 TransparentDataEncryptionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/version.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/version.go new file mode 100644 index 000000000000..abb874756dee --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/version.go @@ -0,0 +1,19 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " sql/2015-05-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualclusters.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualclusters.go new file mode 100644 index 000000000000..a5f661baaf7b --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualclusters.go @@ -0,0 +1,502 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// VirtualClustersClient 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 VirtualClustersClient struct { + BaseClient +} + +// NewVirtualClustersClient creates an instance of the VirtualClustersClient client. +func NewVirtualClustersClient(subscriptionID string) VirtualClustersClient { + return NewVirtualClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualClustersClientWithBaseURI creates an instance of the VirtualClustersClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVirtualClustersClientWithBaseURI(baseURI string, subscriptionID string) VirtualClustersClient { + return VirtualClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) Delete(ctx context.Context, resourceGroupName string, virtualClusterName string) (result VirtualClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2015-05-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/virtualClusters/{virtualClusterName}", 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 VirtualClustersClient) DeleteSender(req *http.Request) (future VirtualClustersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) Get(ctx context.Context, resourceGroupName string, virtualClusterName string) (result VirtualCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "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.VirtualClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + 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/virtualClusters/{virtualClusterName}", 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 VirtualClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) GetResponder(resp *http.Response) (result VirtualCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all virtualClusters in the subscription. +func (client VirtualClustersClient) List(ctx context.Context) (result VirtualClusterListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.List") + defer func() { + sc := -1 + if result.vclr.Response.Response != nil { + sc = result.vclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.vclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", resp, "Failure sending request") + return + } + + result.vclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", resp, "Failure responding to request") + return + } + if result.vclr.hasNextLink() && result.vclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "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}/providers/Microsoft.Sql/virtualClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) ListResponder(resp *http.Response) (result VirtualClusterListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client VirtualClustersClient) listNextResults(ctx context.Context, lastResults VirtualClusterListResult) (result VirtualClusterListResult, err error) { + req, err := lastResults.virtualClusterListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualClustersClient) ListComplete(ctx context.Context) (result VirtualClusterListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of virtual clusters in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client VirtualClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result VirtualClusterListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.vclr.Response.Response != nil { + sc = result.vclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.vclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.vclr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.vclr.hasNextLink() && result.vclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client VirtualClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/virtualClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) ListByResourceGroupResponder(resp *http.Response) (result VirtualClusterListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client VirtualClustersClient) listByResourceGroupNextResults(ctx context.Context, lastResults VirtualClusterListResult) (result VirtualClusterListResult, err error) { + req, err := lastResults.virtualClusterListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualClustersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result VirtualClusterListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +// parameters - the requested managed instance resource state. +func (client VirtualClustersClient) Update(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters VirtualClusterUpdate) (result VirtualClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, virtualClusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters VirtualClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", 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 VirtualClustersClient) UpdateSender(req *http.Request) (future VirtualClustersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) UpdateResponder(resp *http.Response) (result VirtualCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualnetworkrules.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualnetworkrules.go new file mode 100644 index 000000000000..91880b34fb82 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualnetworkrules.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VirtualNetworkRulesClient 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 VirtualNetworkRulesClient struct { + BaseClient +} + +// NewVirtualNetworkRulesClient creates an instance of the VirtualNetworkRulesClient client. +func NewVirtualNetworkRulesClient(subscriptionID string) VirtualNetworkRulesClient { + return NewVirtualNetworkRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworkRulesClientWithBaseURI creates an instance of the VirtualNetworkRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewVirtualNetworkRulesClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkRulesClient { + return VirtualNetworkRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing virtual network rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +// parameters - the requested virtual Network Rule Resource state. +func (client VirtualNetworkRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule) (result VirtualNetworkRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkRuleProperties.VirtualNetworkSubnetID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.VirtualNetworkRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VirtualNetworkRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", 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 VirtualNetworkRulesClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the virtual network rule with the given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualNetworkRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + const APIVersion = "2015-05-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}/virtualNetworkRules/{virtualNetworkRuleName}", 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 VirtualNetworkRulesClient) DeleteSender(req *http.Request) (future VirtualNetworkRulesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual network rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "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.VirtualNetworkRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualNetworkRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + 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}/virtualNetworkRules/{virtualNetworkRuleName}", 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 VirtualNetworkRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) GetResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of virtual network rules in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.ListByServer") + defer func() { + sc := -1 + if result.vnrlr.Response.Response != nil { + sc = result.vnrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.vnrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.vnrlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.vnrlr.hasNextLink() && result.vnrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client VirtualNetworkRulesClient) 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 = "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}/virtualNetworkRules", 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 VirtualNetworkRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) ListByServerResponder(resp *http.Response) (result VirtualNetworkRuleListResult, err error) { + err = autorest.Respond( + resp, + 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 VirtualNetworkRulesClient) listByServerNextResults(ctx context.Context, lastResults VirtualNetworkRuleListResult) (result VirtualNetworkRuleListResult, err error) { + req, err := lastResults.virtualNetworkRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "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.VirtualNetworkRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualNetworkRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/CHANGELOG.md b/services/preview/sql/mgmt/2017-03-01-preview/sql/CHANGELOG.md index 52911e4cc5e4..f24416d8a595 100644 --- a/services/preview/sql/mgmt/2017-03-01-preview/sql/CHANGELOG.md +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/CHANGELOG.md @@ -1,2 +1,41 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Constants + +1. PrimaryAggregationType.Average +1. PrimaryAggregationType.Maximum +1. PrimaryAggregationType.Minimum +1. PrimaryAggregationType.Total +1. UnitDefinitionType.UnitDefinitionTypeBytes +1. UnitDefinitionType.UnitDefinitionTypeBytesPerSecond +1. UnitDefinitionType.UnitDefinitionTypeCount +1. UnitDefinitionType.UnitDefinitionTypeCountPerSecond +1. UnitDefinitionType.UnitDefinitionTypePercent +1. UnitDefinitionType.UnitDefinitionTypeSeconds + +### Signature Changes + +#### Const Types + +1. Count changed type from PrimaryAggregationType to UnitDefinitionType +1. None changed type from PrimaryAggregationType to IdentityType + +## Additive Changes + +### New Constants + +1. IdentityType.SystemAssignedUserAssigned +1. IdentityType.UserAssigned +1. PrimaryAggregationType.PrimaryAggregationTypeAverage +1. PrimaryAggregationType.PrimaryAggregationTypeCount +1. PrimaryAggregationType.PrimaryAggregationTypeMaximum +1. PrimaryAggregationType.PrimaryAggregationTypeMinimum +1. PrimaryAggregationType.PrimaryAggregationTypeNone +1. PrimaryAggregationType.PrimaryAggregationTypeTotal +1. UnitDefinitionType.Bytes +1. UnitDefinitionType.BytesPerSecond +1. UnitDefinitionType.CountPerSecond +1. UnitDefinitionType.Percent +1. UnitDefinitionType.Seconds diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/_meta.json b/services/preview/sql/mgmt/2017-03-01-preview/sql/_meta.json index 355088c31f38..6785ca8c3764 100644 --- a/services/preview/sql/mgmt/2017-03-01-preview/sql/_meta.json +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", "tag": "package-2017-03-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/enums.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/enums.go index 1336aa4ac58f..bc6c7e6d804c 100644 --- a/services/preview/sql/mgmt/2017-03-01-preview/sql/enums.go +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/enums.go @@ -386,13 +386,19 @@ func PossibleGeoBackupPolicyStateValues() []GeoBackupPolicyState { type IdentityType string const ( + // None ... + None IdentityType = "None" // SystemAssigned ... SystemAssigned IdentityType = "SystemAssigned" + // SystemAssignedUserAssigned ... + SystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" + // UserAssigned ... + UserAssigned IdentityType = "UserAssigned" ) // PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. func PossibleIdentityTypeValues() []IdentityType { - return []IdentityType{SystemAssigned} + return []IdentityType{None, SystemAssigned, SystemAssignedUserAssigned, UserAssigned} } // JobAgentState enumerates the values for job agent state. @@ -704,23 +710,23 @@ func PossiblePerformanceLevelUnitValues() []PerformanceLevelUnit { type PrimaryAggregationType string const ( - // Average ... - Average PrimaryAggregationType = "Average" - // Count ... - Count PrimaryAggregationType = "Count" - // Maximum ... - Maximum PrimaryAggregationType = "Maximum" - // Minimum ... - Minimum PrimaryAggregationType = "Minimum" - // None ... - None PrimaryAggregationType = "None" - // Total ... - Total PrimaryAggregationType = "Total" + // PrimaryAggregationTypeAverage ... + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + // PrimaryAggregationTypeCount ... + PrimaryAggregationTypeCount PrimaryAggregationType = "Count" + // PrimaryAggregationTypeMaximum ... + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + // PrimaryAggregationTypeMinimum ... + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + // PrimaryAggregationTypeNone ... + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + // PrimaryAggregationTypeTotal ... + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" ) // PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { - return []PrimaryAggregationType{Average, Count, Maximum, Minimum, None, Total} + return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeCount, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} } // ProvisioningState enumerates the values for provisioning state. @@ -1383,23 +1389,23 @@ func PossibleTransparentDataEncryptionStatusValues() []TransparentDataEncryption type UnitDefinitionType string const ( - // UnitDefinitionTypeBytes ... - UnitDefinitionTypeBytes UnitDefinitionType = "Bytes" - // UnitDefinitionTypeBytesPerSecond ... - UnitDefinitionTypeBytesPerSecond UnitDefinitionType = "BytesPerSecond" - // UnitDefinitionTypeCount ... - UnitDefinitionTypeCount UnitDefinitionType = "Count" - // UnitDefinitionTypeCountPerSecond ... - UnitDefinitionTypeCountPerSecond UnitDefinitionType = "CountPerSecond" - // UnitDefinitionTypePercent ... - UnitDefinitionTypePercent UnitDefinitionType = "Percent" - // UnitDefinitionTypeSeconds ... - UnitDefinitionTypeSeconds UnitDefinitionType = "Seconds" + // Bytes ... + Bytes UnitDefinitionType = "Bytes" + // BytesPerSecond ... + BytesPerSecond UnitDefinitionType = "BytesPerSecond" + // Count ... + Count UnitDefinitionType = "Count" + // CountPerSecond ... + CountPerSecond UnitDefinitionType = "CountPerSecond" + // Percent ... + Percent UnitDefinitionType = "Percent" + // Seconds ... + Seconds UnitDefinitionType = "Seconds" ) // PossibleUnitDefinitionTypeValues returns an array of possible values for the UnitDefinitionType const type. func PossibleUnitDefinitionTypeValues() []UnitDefinitionType { - return []UnitDefinitionType{UnitDefinitionTypeBytes, UnitDefinitionTypeBytesPerSecond, UnitDefinitionTypeCount, UnitDefinitionTypeCountPerSecond, UnitDefinitionTypePercent, UnitDefinitionTypeSeconds} + return []UnitDefinitionType{Bytes, BytesPerSecond, Count, CountPerSecond, Percent, Seconds} } // UnitType enumerates the values for unit type. diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go index 4ff6cc74ad75..2d119e58fe0a 100644 --- a/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go @@ -631,6 +631,9 @@ type DatabaseBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -3707,6 +3710,9 @@ type ExtendedDatabaseBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -4086,6 +4092,9 @@ type ExtendedServerBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -9288,11 +9297,11 @@ func (ma MetricAvailability) MarshalJSON() ([]byte, error) { type MetricDefinition struct { // Name - READ-ONLY; The name information for the metric. Name *MetricName `json:"name,omitempty"` - // PrimaryAggregationType - READ-ONLY; The primary aggregation type defining how metric values are displayed. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + // PrimaryAggregationType - READ-ONLY; The primary aggregation type defining how metric values are displayed. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeCount', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeTotal' PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` // ResourceURI - READ-ONLY; The resource uri of the database. ResourceURI *string `json:"resourceUri,omitempty"` - // Unit - READ-ONLY; The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond' Unit UnitDefinitionType `json:"unit,omitempty"` // MetricAvailabilities - READ-ONLY; The list of database metric availabilities for the metric. MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` @@ -10075,7 +10084,7 @@ func (r Resource) MarshalJSON() ([]byte, error) { type ResourceIdentity struct { // PrincipalID - READ-ONLY; The Azure Active Directory principal id. PrincipalID *uuid.UUID `json:"principalId,omitempty"` - // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'SystemAssigned' + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned' Type IdentityType `json:"type,omitempty"` // TenantID - READ-ONLY; The Azure Active Directory tenant id. TenantID *uuid.UUID `json:"tenantId,omitempty"` @@ -11687,6 +11696,9 @@ type ServerBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/CHANGELOG.md b/services/preview/sql/mgmt/2017-10-01-preview/sql/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/_meta.json b/services/preview/sql/mgmt/2017-10-01-preview/sql/_meta.json new file mode 100644 index 000000000000..8b20774428e1 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", + "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "tag": "package-pure-2017-10-preview", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-pure-2017-10-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/backupshorttermretentionpolicies.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/backupshorttermretentionpolicies.go new file mode 100644 index 000000000000..c9bf2b72f18f --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/backupshorttermretentionpolicies.go @@ -0,0 +1,407 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// BackupShortTermRetentionPoliciesClient 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 BackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewBackupShortTermRetentionPoliciesClient creates an instance of the BackupShortTermRetentionPoliciesClient client. +func NewBackupShortTermRetentionPoliciesClient(subscriptionID string) BackupShortTermRetentionPoliciesClient { + return NewBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// BackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupShortTermRetentionPoliciesClient { + return BackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (result BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 BackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client BackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "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.BackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/backupShortTermRetentionPolicies/{policyName}", 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 BackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.bstrplr.Response.Response != nil { + sc = result.bstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.bstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.bstrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.bstrplr.hasNextLink() && result.bstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabasePreparer(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 = "2017-10-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}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result BackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client BackupShortTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults BackupShortTermRetentionPolicyListResult) (result BackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.backupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// Update updates a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client BackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (result BackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 BackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future BackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/capabilities.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/capabilities.go new file mode 100644 index 000000000000..c7042373e494 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/capabilities.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// CapabilitiesClient 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 CapabilitiesClient struct { + BaseClient +} + +// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. +func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { + return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCapabilitiesClientWithBaseURI creates an instance of the CapabilitiesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the subscription capabilities available for the specified location. +// Parameters: +// locationName - the location name whose capabilities are retrieved. +// include - if specified, restricts the response to only include the selected item. +func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationName string, include CapabilityGroup) (result LocationCapabilities, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByLocationPreparer(ctx, locationName, include) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationName string, include CapabilityGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(include)) > 0 { + queryParameters["include"] = autorest.Encode("query", include) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/client.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/client.go new file mode 100644 index 000000000000..2a09dc10b32d --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/client.go @@ -0,0 +1,42 @@ +// Package sql implements the Azure ARM Sql service API version 2017-10-01-preview. +// +// 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. +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Sql + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Sql. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/databaseoperations.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/databaseoperations.go new file mode 100644 index 000000000000..48ced4d98663 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/databaseoperations.go @@ -0,0 +1,236 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// DatabaseOperationsClient 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 DatabaseOperationsClient struct { + BaseClient +} + +// NewDatabaseOperationsClient creates an instance of the DatabaseOperationsClient client. +func NewDatabaseOperationsClient(subscriptionID string) DatabaseOperationsClient { + return NewDatabaseOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseOperationsClientWithBaseURI creates an instance of the DatabaseOperationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseOperationsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseOperationsClient { + return DatabaseOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// operationID - the operation identifier. +func (client DatabaseOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, databaseName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client DatabaseOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/databases/{databaseName}/operations/{operationId}/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 DatabaseOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase gets a list of operations performed on the database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseOperationsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dolr.Response.Response != nil { + sc = result.dolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dolr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dolr.hasNextLink() && result.dolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseOperationsClient) ListByDatabasePreparer(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 = "2017-10-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}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseOperationsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseOperationsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseOperationListResult) (result DatabaseOperationListResult, err error) { + req, err := lastResults.databaseOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseOperationsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/databases.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/databases.go new file mode 100644 index 000000000000..2ed92b70f267 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/databases.go @@ -0,0 +1,949 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabasesClient 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 DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.DatabaseProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseProperties.CurrentSku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseProperties.CurrentSku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (*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 = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.ManagedBy = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) CreateOrUpdateSender(req *http.Request) (future DatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(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 = "2017-10-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}/databases/{databaseName}", 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 DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "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.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) 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 = "2017-10-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}", 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 DatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByElasticPool gets a list of databases in an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client DatabasesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByElasticPoolNextResults + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client DatabasesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByElasticPoolNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByElasticPoolNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByElasticPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} + +// ListByServer gets a list of databases. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) 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-10-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", 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 DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + 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 DatabasesClient) listByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "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.DatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Pause pauses a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be paused. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Pause") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PausePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "Failure preparing request") + return + } + + result, err = client.PauseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", result.Response(), "Failure sending request") + return + } + + return +} + +// PausePreparer prepares the Pause request. +func (client DatabasesClient) PausePreparer(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 = "2017-10-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}/databases/{databaseName}/pause", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PauseSender sends the Pause request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) PauseSender(req *http.Request) (future DatabasesPauseFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// PauseResponder handles the response to the Pause request. The method always +// closes the http.Response Body. +func (client DatabasesClient) PauseResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Rename renames a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to rename. +// parameters - the resource move definition for renaming this database. +func (client DatabasesClient) Rename(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ResourceMoveDefinition) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Rename") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Rename", err.Error()) + } + + req, err := client.RenamePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", nil, "Failure preparing request") + return + } + + resp, err := client.RenameSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", resp, "Failure sending request") + return + } + + result, err = client.RenameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", resp, "Failure responding to request") + return + } + + return +} + +// RenamePreparer prepares the Rename request. +func (client DatabasesClient) RenamePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ResourceMoveDefinition) (*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 = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RenameSender sends the Rename request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) RenameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RenameResponder handles the response to the Rename request. The method always +// closes the http.Response Body. +func (client DatabasesClient) RenameResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be resumed. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Resume") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ResumePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "Failure preparing request") + return + } + + result, err = client.ResumeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", result.Response(), "Failure sending request") + return + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client DatabasesClient) ResumePreparer(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 = "2017-10-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}/databases/{databaseName}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ResumeSender(req *http.Request) (future DatabasesResumeFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ResumeResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client DatabasesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (result DatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (*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 = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) UpdateSender(req *http.Request) (future DatabasesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeDataWarehouse upgrades a data warehouse. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be upgraded. +func (client DatabasesClient) UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesUpgradeDataWarehouseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.UpgradeDataWarehouse") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpgradeDataWarehousePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "UpgradeDataWarehouse", nil, "Failure preparing request") + return + } + + result, err = client.UpgradeDataWarehouseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "UpgradeDataWarehouse", result.Response(), "Failure sending request") + return + } + + return +} + +// UpgradeDataWarehousePreparer prepares the UpgradeDataWarehouse request. +func (client DatabasesClient) UpgradeDataWarehousePreparer(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 = "2017-10-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}/databases/{databaseName}/upgradeDataWarehouse", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpgradeDataWarehouseSender sends the UpgradeDataWarehouse request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) UpgradeDataWarehouseSender(req *http.Request) (future DatabasesUpgradeDataWarehouseFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpgradeDataWarehouseResponder handles the response to the UpgradeDataWarehouse request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpgradeDataWarehouseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/databasevulnerabilityassessmentscans.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/databasevulnerabilityassessmentscans.go new file mode 100644 index 000000000000..b9e0362af212 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/databasevulnerabilityassessmentscans.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentScansClient 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 DatabaseVulnerabilityAssessmentScansClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentScansClient creates an instance of the DatabaseVulnerabilityAssessmentScansClient +// client. +func NewDatabaseVulnerabilityAssessmentScansClient(subscriptionID string) DatabaseVulnerabilityAssessmentScansClient { + return NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentScansClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentScansClient { + return DatabaseVulnerabilityAssessmentScansClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export convert an existing scan result to a human readable format. If already exists nothing happens +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the scanned database. +// scanID - the vulnerability assessment scan Id. +func (client DatabaseVulnerabilityAssessmentScansClient) Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.Export") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExportPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure responding to request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a vulnerability assessment scan record of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client DatabaseVulnerabilityAssessmentScansClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result VulnerabilityAssessmentScanRecord, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "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.DatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentScansClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", 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 DatabaseVulnerabilityAssessmentScansClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) GetResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecord, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitiateScan executes a Vulnerability Assessment database scan. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScan(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.InitiateScan") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiateScanPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure preparing request") + return + } + + result, err = client.InitiateScanSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "InitiateScan", result.Response(), "Failure sending request") + return + } + + return +} + +// InitiateScanPreparer prepares the InitiateScan request. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateScanSender sends the InitiateScan request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanSender(req *http.Request) (future DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// InitiateScanResponder handles the response to the InitiateScan request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase lists the vulnerability assessment scans of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.vasrlr.Response.Response != nil { + sc = result.vasrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.vasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.vasrlr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.vasrlr.hasNextLink() && result.vasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabasePreparer(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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecordListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseVulnerabilityAssessmentScansClient) listByDatabaseNextResults(ctx context.Context, lastResults VulnerabilityAssessmentScanRecordListResult) (result VulnerabilityAssessmentScanRecordListResult, err error) { + req, err := lastResults.vulnerabilityAssessmentScanRecordListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpooloperations.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpooloperations.go new file mode 100644 index 000000000000..d8bd4555a2cc --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpooloperations.go @@ -0,0 +1,234 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// ElasticPoolOperationsClient 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 ElasticPoolOperationsClient struct { + BaseClient +} + +// NewElasticPoolOperationsClient creates an instance of the ElasticPoolOperationsClient client. +func NewElasticPoolOperationsClient(subscriptionID string) ElasticPoolOperationsClient { + return NewElasticPoolOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolOperationsClientWithBaseURI creates an instance of the ElasticPoolOperationsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewElasticPoolOperationsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolOperationsClient { + return ElasticPoolOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// operationID - the operation identifier. +func (client ElasticPoolOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, elasticPoolName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client ElasticPoolOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}/operations/{operationId}/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 ElasticPoolOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByElasticPool gets a list of operations performed on the elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ElasticPoolOperationsClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.ListByElasticPool") + defer func() { + sc := -1 + if result.epolr.Response.Response != nil { + sc = result.epolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByElasticPoolNextResults + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.epolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result.epolr, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + if result.epolr.hasNextLink() && result.epolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolOperationsClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolOperationsClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByElasticPoolNextResults retrieves the next set of results, if any. +func (client ElasticPoolOperationsClient) listByElasticPoolNextResults(ctx context.Context, lastResults ElasticPoolOperationListResult) (result ElasticPoolOperationListResult, err error) { + req, err := lastResults.elasticPoolOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByElasticPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client ElasticPoolOperationsClient) ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpools.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpools.go new file mode 100644 index 000000000000..fbb54bf4cb1d --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpools.go @@ -0,0 +1,495 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ElasticPoolsClient 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 ElasticPoolsClient struct { + BaseClient +} + +// NewElasticPoolsClient creates an instance of the ElasticPoolsClient client. +func NewElasticPoolsClient(subscriptionID string) ElasticPoolsClient { + return NewElasticPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolsClientWithBaseURI creates an instance of the ElasticPoolsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +// parameters - the elastic pool parameters. +func (client ElasticPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (result ElasticPoolsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ElasticPoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ElasticPoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) CreateOrUpdateSender(req *http.Request) (future ElasticPoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ElasticPoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) DeleteSender(req *http.Request) (future ElasticPoolsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "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.ElasticPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ElasticPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all elastic pools in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// skip - the number of elements in the collection to skip. +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.eplr.Response.Response != nil { + sc = result.eplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.eplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.eplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.eplr.hasNextLink() && result.eplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ElasticPoolsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (*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-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if skip != nil { + 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}/elasticPools", 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 ElasticPoolsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + 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 ElasticPoolsClient) listByServerNextResults(ctx context.Context, lastResults ElasticPoolListResult) (result ElasticPoolListResult, err error) { + req, err := lastResults.elasticPoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "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.ElasticPoolsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ElasticPoolsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName, skip) + return +} + +// Update updates an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +// parameters - the elastic pool update parameters. +func (client ElasticPoolsClient) Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (result ElasticPoolsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ElasticPoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) UpdateSender(req *http.Request) (future ElasticPoolsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/enums.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/enums.go new file mode 100644 index 000000000000..a7ed4ce7220d --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/enums.go @@ -0,0 +1,409 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// CapabilityGroup enumerates the values for capability group. +type CapabilityGroup string + +const ( + // SupportedEditions ... + SupportedEditions CapabilityGroup = "supportedEditions" + // SupportedElasticPoolEditions ... + SupportedElasticPoolEditions CapabilityGroup = "supportedElasticPoolEditions" + // SupportedManagedInstanceVersions ... + SupportedManagedInstanceVersions CapabilityGroup = "supportedManagedInstanceVersions" +) + +// PossibleCapabilityGroupValues returns an array of possible values for the CapabilityGroup const type. +func PossibleCapabilityGroupValues() []CapabilityGroup { + return []CapabilityGroup{SupportedEditions, SupportedElasticPoolEditions, SupportedManagedInstanceVersions} +} + +// CapabilityStatus enumerates the values for capability status. +type CapabilityStatus string + +const ( + // Available ... + Available CapabilityStatus = "Available" + // Default ... + Default CapabilityStatus = "Default" + // Disabled ... + Disabled CapabilityStatus = "Disabled" + // Visible ... + Visible CapabilityStatus = "Visible" +) + +// PossibleCapabilityStatusValues returns an array of possible values for the CapabilityStatus const type. +func PossibleCapabilityStatusValues() []CapabilityStatus { + return []CapabilityStatus{Available, Default, Disabled, Visible} +} + +// CatalogCollationType enumerates the values for catalog collation type. +type CatalogCollationType string + +const ( + // DATABASEDEFAULT ... + DATABASEDEFAULT CatalogCollationType = "DATABASE_DEFAULT" + // SQLLatin1GeneralCP1CIAS ... + SQLLatin1GeneralCP1CIAS CatalogCollationType = "SQL_Latin1_General_CP1_CI_AS" +) + +// PossibleCatalogCollationTypeValues returns an array of possible values for the CatalogCollationType const type. +func PossibleCatalogCollationTypeValues() []CatalogCollationType { + return []CatalogCollationType{DATABASEDEFAULT, SQLLatin1GeneralCP1CIAS} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // CreateModeCopy ... + CreateModeCopy CreateMode = "Copy" + // CreateModeDefault ... + CreateModeDefault CreateMode = "Default" + // CreateModeOnlineSecondary ... + CreateModeOnlineSecondary CreateMode = "OnlineSecondary" + // CreateModePointInTimeRestore ... + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeRecovery ... + CreateModeRecovery CreateMode = "Recovery" + // CreateModeRestore ... + CreateModeRestore CreateMode = "Restore" + // CreateModeRestoreExternalBackup ... + CreateModeRestoreExternalBackup CreateMode = "RestoreExternalBackup" + // CreateModeRestoreExternalBackupSecondary ... + CreateModeRestoreExternalBackupSecondary CreateMode = "RestoreExternalBackupSecondary" + // CreateModeRestoreLongTermRetentionBackup ... + CreateModeRestoreLongTermRetentionBackup CreateMode = "RestoreLongTermRetentionBackup" + // CreateModeSecondary ... + CreateModeSecondary CreateMode = "Secondary" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeCopy, CreateModeDefault, CreateModeOnlineSecondary, CreateModePointInTimeRestore, CreateModeRecovery, CreateModeRestore, CreateModeRestoreExternalBackup, CreateModeRestoreExternalBackupSecondary, CreateModeRestoreLongTermRetentionBackup, CreateModeSecondary} +} + +// DatabaseLicenseType enumerates the values for database license type. +type DatabaseLicenseType string + +const ( + // BasePrice ... + BasePrice DatabaseLicenseType = "BasePrice" + // LicenseIncluded ... + LicenseIncluded DatabaseLicenseType = "LicenseIncluded" +) + +// PossibleDatabaseLicenseTypeValues returns an array of possible values for the DatabaseLicenseType const type. +func PossibleDatabaseLicenseTypeValues() []DatabaseLicenseType { + return []DatabaseLicenseType{BasePrice, LicenseIncluded} +} + +// DatabaseReadScale enumerates the values for database read scale. +type DatabaseReadScale string + +const ( + // DatabaseReadScaleDisabled ... + DatabaseReadScaleDisabled DatabaseReadScale = "Disabled" + // DatabaseReadScaleEnabled ... + DatabaseReadScaleEnabled DatabaseReadScale = "Enabled" +) + +// PossibleDatabaseReadScaleValues returns an array of possible values for the DatabaseReadScale const type. +func PossibleDatabaseReadScaleValues() []DatabaseReadScale { + return []DatabaseReadScale{DatabaseReadScaleDisabled, DatabaseReadScaleEnabled} +} + +// DatabaseStatus enumerates the values for database status. +type DatabaseStatus string + +const ( + // DatabaseStatusAutoClosed ... + DatabaseStatusAutoClosed DatabaseStatus = "AutoClosed" + // DatabaseStatusCopying ... + DatabaseStatusCopying DatabaseStatus = "Copying" + // DatabaseStatusCreating ... + DatabaseStatusCreating DatabaseStatus = "Creating" + // DatabaseStatusDisabled ... + DatabaseStatusDisabled DatabaseStatus = "Disabled" + // DatabaseStatusEmergencyMode ... + DatabaseStatusEmergencyMode DatabaseStatus = "EmergencyMode" + // DatabaseStatusInaccessible ... + DatabaseStatusInaccessible DatabaseStatus = "Inaccessible" + // DatabaseStatusOffline ... + DatabaseStatusOffline DatabaseStatus = "Offline" + // DatabaseStatusOfflineChangingDwPerformanceTiers ... + DatabaseStatusOfflineChangingDwPerformanceTiers DatabaseStatus = "OfflineChangingDwPerformanceTiers" + // DatabaseStatusOfflineSecondary ... + DatabaseStatusOfflineSecondary DatabaseStatus = "OfflineSecondary" + // DatabaseStatusOnline ... + DatabaseStatusOnline DatabaseStatus = "Online" + // DatabaseStatusOnlineChangingDwPerformanceTiers ... + DatabaseStatusOnlineChangingDwPerformanceTiers DatabaseStatus = "OnlineChangingDwPerformanceTiers" + // DatabaseStatusPaused ... + DatabaseStatusPaused DatabaseStatus = "Paused" + // DatabaseStatusPausing ... + DatabaseStatusPausing DatabaseStatus = "Pausing" + // DatabaseStatusRecovering ... + DatabaseStatusRecovering DatabaseStatus = "Recovering" + // DatabaseStatusRecoveryPending ... + DatabaseStatusRecoveryPending DatabaseStatus = "RecoveryPending" + // DatabaseStatusRestoring ... + DatabaseStatusRestoring DatabaseStatus = "Restoring" + // DatabaseStatusResuming ... + DatabaseStatusResuming DatabaseStatus = "Resuming" + // DatabaseStatusScaling ... + DatabaseStatusScaling DatabaseStatus = "Scaling" + // DatabaseStatusShutdown ... + DatabaseStatusShutdown DatabaseStatus = "Shutdown" + // DatabaseStatusStandby ... + DatabaseStatusStandby DatabaseStatus = "Standby" + // DatabaseStatusSuspect ... + DatabaseStatusSuspect DatabaseStatus = "Suspect" +) + +// PossibleDatabaseStatusValues returns an array of possible values for the DatabaseStatus const type. +func PossibleDatabaseStatusValues() []DatabaseStatus { + return []DatabaseStatus{DatabaseStatusAutoClosed, DatabaseStatusCopying, DatabaseStatusCreating, DatabaseStatusDisabled, DatabaseStatusEmergencyMode, DatabaseStatusInaccessible, DatabaseStatusOffline, DatabaseStatusOfflineChangingDwPerformanceTiers, DatabaseStatusOfflineSecondary, DatabaseStatusOnline, DatabaseStatusOnlineChangingDwPerformanceTiers, DatabaseStatusPaused, DatabaseStatusPausing, DatabaseStatusRecovering, DatabaseStatusRecoveryPending, DatabaseStatusRestoring, DatabaseStatusResuming, DatabaseStatusScaling, DatabaseStatusShutdown, DatabaseStatusStandby, DatabaseStatusSuspect} +} + +// ElasticPoolLicenseType enumerates the values for elastic pool license type. +type ElasticPoolLicenseType string + +const ( + // ElasticPoolLicenseTypeBasePrice ... + ElasticPoolLicenseTypeBasePrice ElasticPoolLicenseType = "BasePrice" + // ElasticPoolLicenseTypeLicenseIncluded ... + ElasticPoolLicenseTypeLicenseIncluded ElasticPoolLicenseType = "LicenseIncluded" +) + +// PossibleElasticPoolLicenseTypeValues returns an array of possible values for the ElasticPoolLicenseType const type. +func PossibleElasticPoolLicenseTypeValues() []ElasticPoolLicenseType { + return []ElasticPoolLicenseType{ElasticPoolLicenseTypeBasePrice, ElasticPoolLicenseTypeLicenseIncluded} +} + +// ElasticPoolState enumerates the values for elastic pool state. +type ElasticPoolState string + +const ( + // ElasticPoolStateCreating ... + ElasticPoolStateCreating ElasticPoolState = "Creating" + // ElasticPoolStateDisabled ... + ElasticPoolStateDisabled ElasticPoolState = "Disabled" + // ElasticPoolStateReady ... + ElasticPoolStateReady ElasticPoolState = "Ready" +) + +// PossibleElasticPoolStateValues returns an array of possible values for the ElasticPoolState const type. +func PossibleElasticPoolStateValues() []ElasticPoolState { + return []ElasticPoolState{ElasticPoolStateCreating, ElasticPoolStateDisabled, ElasticPoolStateReady} +} + +// InstanceFailoverGroupReplicationRole enumerates the values for instance failover group replication role. +type InstanceFailoverGroupReplicationRole string + +const ( + // Primary ... + Primary InstanceFailoverGroupReplicationRole = "Primary" + // Secondary ... + Secondary InstanceFailoverGroupReplicationRole = "Secondary" +) + +// PossibleInstanceFailoverGroupReplicationRoleValues returns an array of possible values for the InstanceFailoverGroupReplicationRole const type. +func PossibleInstanceFailoverGroupReplicationRoleValues() []InstanceFailoverGroupReplicationRole { + return []InstanceFailoverGroupReplicationRole{Primary, Secondary} +} + +// LogSizeUnit enumerates the values for log size unit. +type LogSizeUnit string + +const ( + // Gigabytes ... + Gigabytes LogSizeUnit = "Gigabytes" + // Megabytes ... + Megabytes LogSizeUnit = "Megabytes" + // Percent ... + Percent LogSizeUnit = "Percent" + // Petabytes ... + Petabytes LogSizeUnit = "Petabytes" + // Terabytes ... + Terabytes LogSizeUnit = "Terabytes" +) + +// PossibleLogSizeUnitValues returns an array of possible values for the LogSizeUnit const type. +func PossibleLogSizeUnitValues() []LogSizeUnit { + return []LogSizeUnit{Gigabytes, Megabytes, Percent, Petabytes, Terabytes} +} + +// ManagementOperationState enumerates the values for management operation state. +type ManagementOperationState string + +const ( + // CancelInProgress ... + CancelInProgress ManagementOperationState = "CancelInProgress" + // Cancelled ... + Cancelled ManagementOperationState = "Cancelled" + // Failed ... + Failed ManagementOperationState = "Failed" + // InProgress ... + InProgress ManagementOperationState = "InProgress" + // Pending ... + Pending ManagementOperationState = "Pending" + // Succeeded ... + Succeeded ManagementOperationState = "Succeeded" +) + +// PossibleManagementOperationStateValues returns an array of possible values for the ManagementOperationState const type. +func PossibleManagementOperationStateValues() []ManagementOperationState { + return []ManagementOperationState{CancelInProgress, Cancelled, Failed, InProgress, Pending, Succeeded} +} + +// MaxSizeUnit enumerates the values for max size unit. +type MaxSizeUnit string + +const ( + // MaxSizeUnitGigabytes ... + MaxSizeUnitGigabytes MaxSizeUnit = "Gigabytes" + // MaxSizeUnitMegabytes ... + MaxSizeUnitMegabytes MaxSizeUnit = "Megabytes" + // MaxSizeUnitPetabytes ... + MaxSizeUnitPetabytes MaxSizeUnit = "Petabytes" + // MaxSizeUnitTerabytes ... + MaxSizeUnitTerabytes MaxSizeUnit = "Terabytes" +) + +// PossibleMaxSizeUnitValues returns an array of possible values for the MaxSizeUnit const type. +func PossibleMaxSizeUnitValues() []MaxSizeUnit { + return []MaxSizeUnit{MaxSizeUnitGigabytes, MaxSizeUnitMegabytes, MaxSizeUnitPetabytes, MaxSizeUnitTerabytes} +} + +// PerformanceLevelUnit enumerates the values for performance level unit. +type PerformanceLevelUnit string + +const ( + // DTU ... + DTU PerformanceLevelUnit = "DTU" + // VCores ... + VCores PerformanceLevelUnit = "VCores" +) + +// PossiblePerformanceLevelUnitValues returns an array of possible values for the PerformanceLevelUnit const type. +func PossiblePerformanceLevelUnitValues() []PerformanceLevelUnit { + return []PerformanceLevelUnit{DTU, VCores} +} + +// ReadOnlyEndpointFailoverPolicy enumerates the values for read only endpoint failover policy. +type ReadOnlyEndpointFailoverPolicy string + +const ( + // ReadOnlyEndpointFailoverPolicyDisabled ... + ReadOnlyEndpointFailoverPolicyDisabled ReadOnlyEndpointFailoverPolicy = "Disabled" + // ReadOnlyEndpointFailoverPolicyEnabled ... + ReadOnlyEndpointFailoverPolicyEnabled ReadOnlyEndpointFailoverPolicy = "Enabled" +) + +// PossibleReadOnlyEndpointFailoverPolicyValues returns an array of possible values for the ReadOnlyEndpointFailoverPolicy const type. +func PossibleReadOnlyEndpointFailoverPolicyValues() []ReadOnlyEndpointFailoverPolicy { + return []ReadOnlyEndpointFailoverPolicy{ReadOnlyEndpointFailoverPolicyDisabled, ReadOnlyEndpointFailoverPolicyEnabled} +} + +// ReadWriteEndpointFailoverPolicy enumerates the values for read write endpoint failover policy. +type ReadWriteEndpointFailoverPolicy string + +const ( + // Automatic ... + Automatic ReadWriteEndpointFailoverPolicy = "Automatic" + // Manual ... + Manual ReadWriteEndpointFailoverPolicy = "Manual" +) + +// PossibleReadWriteEndpointFailoverPolicyValues returns an array of possible values for the ReadWriteEndpointFailoverPolicy const type. +func PossibleReadWriteEndpointFailoverPolicyValues() []ReadWriteEndpointFailoverPolicy { + return []ReadWriteEndpointFailoverPolicy{Automatic, Manual} +} + +// SampleName enumerates the values for sample name. +type SampleName string + +const ( + // AdventureWorksLT ... + AdventureWorksLT SampleName = "AdventureWorksLT" + // WideWorldImportersFull ... + WideWorldImportersFull SampleName = "WideWorldImportersFull" + // WideWorldImportersStd ... + WideWorldImportersStd SampleName = "WideWorldImportersStd" +) + +// PossibleSampleNameValues returns an array of possible values for the SampleName const type. +func PossibleSampleNameValues() []SampleName { + return []SampleName{AdventureWorksLT, WideWorldImportersFull, WideWorldImportersStd} +} + +// ServerKeyType enumerates the values for server key type. +type ServerKeyType string + +const ( + // AzureKeyVault ... + AzureKeyVault ServerKeyType = "AzureKeyVault" + // ServiceManaged ... + ServiceManaged ServerKeyType = "ServiceManaged" +) + +// PossibleServerKeyTypeValues returns an array of possible values for the ServerKeyType const type. +func PossibleServerKeyTypeValues() []ServerKeyType { + return []ServerKeyType{AzureKeyVault, ServiceManaged} +} + +// VulnerabilityAssessmentPolicyBaselineName enumerates the values for vulnerability assessment policy baseline +// name. +type VulnerabilityAssessmentPolicyBaselineName string + +const ( + // VulnerabilityAssessmentPolicyBaselineNameDefault ... + VulnerabilityAssessmentPolicyBaselineNameDefault VulnerabilityAssessmentPolicyBaselineName = "default" + // VulnerabilityAssessmentPolicyBaselineNameMaster ... + VulnerabilityAssessmentPolicyBaselineNameMaster VulnerabilityAssessmentPolicyBaselineName = "master" +) + +// PossibleVulnerabilityAssessmentPolicyBaselineNameValues returns an array of possible values for the VulnerabilityAssessmentPolicyBaselineName const type. +func PossibleVulnerabilityAssessmentPolicyBaselineNameValues() []VulnerabilityAssessmentPolicyBaselineName { + return []VulnerabilityAssessmentPolicyBaselineName{VulnerabilityAssessmentPolicyBaselineNameDefault, VulnerabilityAssessmentPolicyBaselineNameMaster} +} + +// VulnerabilityAssessmentScanState enumerates the values for vulnerability assessment scan state. +type VulnerabilityAssessmentScanState string + +const ( + // VulnerabilityAssessmentScanStateFailed ... + VulnerabilityAssessmentScanStateFailed VulnerabilityAssessmentScanState = "Failed" + // VulnerabilityAssessmentScanStateFailedToRun ... + VulnerabilityAssessmentScanStateFailedToRun VulnerabilityAssessmentScanState = "FailedToRun" + // VulnerabilityAssessmentScanStateInProgress ... + VulnerabilityAssessmentScanStateInProgress VulnerabilityAssessmentScanState = "InProgress" + // VulnerabilityAssessmentScanStatePassed ... + VulnerabilityAssessmentScanStatePassed VulnerabilityAssessmentScanState = "Passed" +) + +// PossibleVulnerabilityAssessmentScanStateValues returns an array of possible values for the VulnerabilityAssessmentScanState const type. +func PossibleVulnerabilityAssessmentScanStateValues() []VulnerabilityAssessmentScanState { + return []VulnerabilityAssessmentScanState{VulnerabilityAssessmentScanStateFailed, VulnerabilityAssessmentScanStateFailedToRun, VulnerabilityAssessmentScanStateInProgress, VulnerabilityAssessmentScanStatePassed} +} + +// VulnerabilityAssessmentScanTriggerType enumerates the values for vulnerability assessment scan trigger type. +type VulnerabilityAssessmentScanTriggerType string + +const ( + // OnDemand ... + OnDemand VulnerabilityAssessmentScanTriggerType = "OnDemand" + // Recurring ... + Recurring VulnerabilityAssessmentScanTriggerType = "Recurring" +) + +// PossibleVulnerabilityAssessmentScanTriggerTypeValues returns an array of possible values for the VulnerabilityAssessmentScanTriggerType const type. +func PossibleVulnerabilityAssessmentScanTriggerTypeValues() []VulnerabilityAssessmentScanTriggerType { + return []VulnerabilityAssessmentScanTriggerType{OnDemand, Recurring} +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go new file mode 100644 index 000000000000..fc2759bfaa00 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go @@ -0,0 +1,574 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InstanceFailoverGroupsClient 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 InstanceFailoverGroupsClient struct { + BaseClient +} + +// NewInstanceFailoverGroupsClient creates an instance of the InstanceFailoverGroupsClient client. +func NewInstanceFailoverGroupsClient(subscriptionID string) InstanceFailoverGroupsClient { + return NewInstanceFailoverGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInstanceFailoverGroupsClientWithBaseURI creates an instance of the InstanceFailoverGroupsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return InstanceFailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client InstanceFailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (result InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.InstanceFailoverGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstanceFailoverGroupProperties.PartnerRegions", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstanceFailoverGroupProperties.ManagedInstancePairs", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.InstanceFailoverGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, locationName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client InstanceFailoverGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", 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 InstanceFailoverGroupsClient) CreateOrUpdateSender(req *http.Request) (future InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client InstanceFailoverGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", 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 InstanceFailoverGroupsClient) DeleteSender(req *http.Request) (future InstanceFailoverGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary managed instance to this managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client InstanceFailoverGroupsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) FailoverSender(req *http.Request) (future InstanceFailoverGroupsFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) FailoverResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ForceFailoverAllowDataLoss fails over from the current primary managed instance to this managed instance. This +// operation might result in data loss. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ForceFailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ForceFailoverAllowDataLossPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.ForceFailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ForceFailoverAllowDataLoss", result.Response(), "Failure sending request") + return + } + + return +} + +// ForceFailoverAllowDataLossPreparer prepares the ForceFailoverAllowDataLoss request. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ForceFailoverAllowDataLossSender sends the ForceFailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossSender(req *http.Request) (future InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ForceFailoverAllowDataLossResponder handles the response to the ForceFailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "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.InstanceFailoverGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client InstanceFailoverGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", 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 InstanceFailoverGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) GetResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists the failover groups in a location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +func (client InstanceFailoverGroupsClient) ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result InstanceFailoverGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.ifglr.Response.Response != nil { + sc = result.ifglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, resourceGroupName, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.ifglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.ifglr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.ifglr.hasNextLink() && result.ifglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client InstanceFailoverGroupsClient) ListByLocationPreparer(ctx context.Context, resourceGroupName string, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) ListByLocationResponder(resp *http.Response) (result InstanceFailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client InstanceFailoverGroupsClient) listByLocationNextResults(ctx context.Context, lastResults InstanceFailoverGroupListResult) (result InstanceFailoverGroupListResult, err error) { + req, err := lastResults.instanceFailoverGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstanceFailoverGroupsClient) ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result InstanceFailoverGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentrulebaselines.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentrulebaselines.go new file mode 100644 index 000000000000..7c9fb47a1e5f --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentrulebaselines.go @@ -0,0 +1,300 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient client. +func NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient { + return NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient { + return ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +// parameters - the requested rule baseline resource. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties.BaselineResults", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "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.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "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.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessments.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessments.go new file mode 100644 index 000000000000..888234d2681c --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessments.go @@ -0,0 +1,398 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentsClient 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 ManagedDatabaseVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentsClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentsClient client. +func NewManagedDatabaseVulnerabilityAssessmentsClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentsClient { + return NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentsClient { + return ManagedDatabaseVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "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.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedDatabaseVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "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.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedDatabaseVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists the vulnerability assessments of a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dvalr.Response.Response != nil { + sc = result.dvalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dvalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dvalr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dvalr.hasNextLink() && result.dvalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseVulnerabilityAssessmentListResult) (result DatabaseVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.databaseVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentscans.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentscans.go new file mode 100644 index 000000000000..d5bea2ebbb00 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/manageddatabasevulnerabilityassessmentscans.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentScansClient 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 ManagedDatabaseVulnerabilityAssessmentScansClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentScansClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentScansClient client. +func NewManagedDatabaseVulnerabilityAssessmentScansClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentScansClient { + return NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentScansClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentScansClient { + return ManagedDatabaseVulnerabilityAssessmentScansClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export convert an existing scan result to a human readable format. If already exists nothing happens +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the scanned database. +// scanID - the vulnerability assessment scan Id. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) Export(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.Export") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExportPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure responding to request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a vulnerability assessment scan record of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result VulnerabilityAssessmentScanRecord, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "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.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", 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 ManagedDatabaseVulnerabilityAssessmentScansClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecord, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitiateScan executes a Vulnerability Assessment database scan. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScan(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.InitiateScan") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiateScanPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure preparing request") + return + } + + result, err = client.InitiateScanSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "InitiateScan", result.Response(), "Failure sending request") + return + } + + return +} + +// InitiateScanPreparer prepares the InitiateScan request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateScanSender sends the InitiateScan request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanSender(req *http.Request) (future ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// InitiateScanResponder handles the response to the InitiateScan request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase lists the vulnerability assessment scans of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.vasrlr.Response.Response != nil { + sc = result.vasrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.vasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.vasrlr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.vasrlr.hasNextLink() && result.vasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecordListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) listByDatabaseNextResults(ctx context.Context, lastResults VulnerabilityAssessmentScanRecordListResult) (result VulnerabilityAssessmentScanRecordListResult, err error) { + req, err := lastResults.vulnerabilityAssessmentScanRecordListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstanceencryptionprotectors.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstanceencryptionprotectors.go new file mode 100644 index 000000000000..d1e8429e5263 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstanceencryptionprotectors.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedInstanceEncryptionProtectorsClient 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 ManagedInstanceEncryptionProtectorsClient struct { + BaseClient +} + +// NewManagedInstanceEncryptionProtectorsClient creates an instance of the ManagedInstanceEncryptionProtectorsClient +// client. +func NewManagedInstanceEncryptionProtectorsClient(subscriptionID string) ManagedInstanceEncryptionProtectorsClient { + return NewManagedInstanceEncryptionProtectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceEncryptionProtectorsClientWithBaseURI creates an instance of the +// ManagedInstanceEncryptionProtectorsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceEncryptionProtectorsClient { + return ManagedInstanceEncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested encryption protector resource state. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceEncryptionProtector) (result ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceEncryptionProtector) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", 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 ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceEncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed instance encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "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.ManagedInstanceEncryptionProtectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceEncryptionProtectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", 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 ManagedInstanceEncryptionProtectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) GetResponder(resp *http.Response) (result ManagedInstanceEncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance encryption protectors +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.ListByInstance") + defer func() { + sc := -1 + if result.mieplr.Response.Response != nil { + sc = result.mieplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mieplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mieplr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mieplr.hasNextLink() && result.mieplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/encryptionProtector", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceEncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceEncryptionProtectorsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceEncryptionProtectorListResult) (result ManagedInstanceEncryptionProtectorListResult, err error) { + req, err := lastResults.managedInstanceEncryptionProtectorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Revalidate revalidates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) Revalidate(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.Revalidate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RevalidatePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Revalidate", nil, "Failure preparing request") + return + } + + result, err = client.RevalidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Revalidate", result.Response(), "Failure sending request") + return + } + + return +} + +// RevalidatePreparer prepares the Revalidate request. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevalidateSender sends the Revalidate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidateSender(req *http.Request) (future ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RevalidateResponder handles the response to the Revalidate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancekeys.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancekeys.go new file mode 100644 index 000000000000..a4f4e479a482 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancekeys.go @@ -0,0 +1,403 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedInstanceKeysClient 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 ManagedInstanceKeysClient struct { + BaseClient +} + +// NewManagedInstanceKeysClient creates an instance of the ManagedInstanceKeysClient client. +func NewManagedInstanceKeysClient(subscriptionID string) ManagedInstanceKeysClient { + return NewManagedInstanceKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceKeysClientWithBaseURI creates an instance of the ManagedInstanceKeysClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedInstanceKeysClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceKeysClient { + return ManagedInstanceKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be operated on (updated or created). +// parameters - the requested managed instance key resource state. +func (client ManagedInstanceKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters ManagedInstanceKey) (result ManagedInstanceKeysCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceKeysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters ManagedInstanceKey) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", 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 ManagedInstanceKeysClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceKeysCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed instance key with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be deleted. +func (client ManagedInstanceKeysClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result ManagedInstanceKeysDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/keys/{keyName}", 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 ManagedInstanceKeysClient) DeleteSender(req *http.Request) (future ManagedInstanceKeysDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be retrieved. +func (client ManagedInstanceKeysClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result ManagedInstanceKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "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.ManagedInstanceKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/keys/{keyName}", 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 ManagedInstanceKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) GetResponder(resp *http.Response) (result ManagedInstanceKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance keys. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedInstanceKeysClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result ManagedInstanceKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.ListByInstance") + defer func() { + sc := -1 + if result.miklr.Response.Response != nil { + sc = result.miklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miklr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miklr.hasNextLink() && result.miklr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceKeysClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceKeysClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceKeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceKeysClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceKeyListResult) (result ManagedInstanceKeyListResult, err error) { + req, err := lastResults.managedInstanceKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceKeysClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result ManagedInstanceKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName, filter) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancetdecertificates.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancetdecertificates.go new file mode 100644 index 000000000000..3b0f0fd7c404 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/managedinstancetdecertificates.go @@ -0,0 +1,124 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceTdeCertificatesClient 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 ManagedInstanceTdeCertificatesClient struct { + BaseClient +} + +// NewManagedInstanceTdeCertificatesClient creates an instance of the ManagedInstanceTdeCertificatesClient client. +func NewManagedInstanceTdeCertificatesClient(subscriptionID string) ManagedInstanceTdeCertificatesClient { + return NewManagedInstanceTdeCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceTdeCertificatesClientWithBaseURI creates an instance of the ManagedInstanceTdeCertificatesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedInstanceTdeCertificatesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceTdeCertificatesClient { + return ManagedInstanceTdeCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a TDE certificate for a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested TDE certificate to be created or updated. +func (client ManagedInstanceTdeCertificatesClient) Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters TdeCertificate) (result ManagedInstanceTdeCertificatesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceTdeCertificatesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TdeCertificateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TdeCertificateProperties.PrivateBlob", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceTdeCertificatesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ManagedInstanceTdeCertificatesClient) CreatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters TdeCertificate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates", pathParameters), + autorest.WithJSON(parameters), + 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 ManagedInstanceTdeCertificatesClient) CreateSender(req *http.Request) (future ManagedInstanceTdeCertificatesCreateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ManagedInstanceTdeCertificatesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/models.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/models.go new file mode 100644 index 000000000000..b1bcb9c4ba03 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/models.go @@ -0,0 +1,5051 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-10-01-preview/sql" + +// BackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type BackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupShortTermRetentionPoliciesClient) (BackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *BackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client BackupShortTermRetentionPoliciesClient) (bstrp BackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bstrp.Response.Response, err = future.GetResult(sender); err == nil && bstrp.Response.Response.StatusCode != http.StatusNoContent { + bstrp, err = client.CreateOrUpdateResponder(bstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", bstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type BackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupShortTermRetentionPoliciesClient) (BackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *BackupShortTermRetentionPoliciesUpdateFuture) result(client BackupShortTermRetentionPoliciesClient) (bstrp BackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bstrp.Response.Response, err = future.GetResult(sender); err == nil && bstrp.Response.Response.StatusCode != http.StatusNoContent { + bstrp, err = client.UpdateResponder(bstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesUpdateFuture", "Result", bstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupShortTermRetentionPolicy a short term retention policy. +type BackupShortTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BackupShortTermRetentionPolicyProperties - Resource properties. + *BackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupShortTermRetentionPolicy. +func (bstrp BackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bstrp.BackupShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = bstrp.BackupShortTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupShortTermRetentionPolicy struct. +func (bstrp *BackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var backupShortTermRetentionPolicyProperties BackupShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &backupShortTermRetentionPolicyProperties) + if err != nil { + return err + } + bstrp.BackupShortTermRetentionPolicyProperties = &backupShortTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bstrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bstrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bstrp.Type = &typeVar + } + } + } + + return nil +} + +// BackupShortTermRetentionPolicyListResult a list of short term retention policies. +type BackupShortTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]BackupShortTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupShortTermRetentionPolicyListResult. +func (bstrplr BackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// BackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of +// BackupShortTermRetentionPolicy values. +type BackupShortTermRetentionPolicyListResultIterator struct { + i int + page BackupShortTermRetentionPolicyListResultPage +} + +// NextWithContext 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 *BackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *BackupShortTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BackupShortTermRetentionPolicyListResultIterator) 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 BackupShortTermRetentionPolicyListResultIterator) Response() BackupShortTermRetentionPolicyListResult { + 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 BackupShortTermRetentionPolicyListResultIterator) Value() BackupShortTermRetentionPolicy { + if !iter.page.NotDone() { + return BackupShortTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the BackupShortTermRetentionPolicyListResultIterator type. +func NewBackupShortTermRetentionPolicyListResultIterator(page BackupShortTermRetentionPolicyListResultPage) BackupShortTermRetentionPolicyListResultIterator { + return BackupShortTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (bstrplr BackupShortTermRetentionPolicyListResult) IsEmpty() bool { + return bstrplr.Value == nil || len(*bstrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (bstrplr BackupShortTermRetentionPolicyListResult) hasNextLink() bool { + return bstrplr.NextLink != nil && len(*bstrplr.NextLink) != 0 +} + +// backupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (bstrplr BackupShortTermRetentionPolicyListResult) backupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !bstrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(bstrplr.NextLink))) +} + +// BackupShortTermRetentionPolicyListResultPage contains a page of BackupShortTermRetentionPolicy values. +type BackupShortTermRetentionPolicyListResultPage struct { + fn func(context.Context, BackupShortTermRetentionPolicyListResult) (BackupShortTermRetentionPolicyListResult, error) + bstrplr BackupShortTermRetentionPolicyListResult +} + +// NextWithContext 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 *BackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.bstrplr) + if err != nil { + return err + } + page.bstrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *BackupShortTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BackupShortTermRetentionPolicyListResultPage) NotDone() bool { + return !page.bstrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BackupShortTermRetentionPolicyListResultPage) Response() BackupShortTermRetentionPolicyListResult { + return page.bstrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BackupShortTermRetentionPolicyListResultPage) Values() []BackupShortTermRetentionPolicy { + if page.bstrplr.IsEmpty() { + return nil + } + return *page.bstrplr.Value +} + +// Creates a new instance of the BackupShortTermRetentionPolicyListResultPage type. +func NewBackupShortTermRetentionPolicyListResultPage(cur BackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, BackupShortTermRetentionPolicyListResult) (BackupShortTermRetentionPolicyListResult, error)) BackupShortTermRetentionPolicyListResultPage { + return BackupShortTermRetentionPolicyListResultPage{ + fn: getNextPage, + bstrplr: cur, + } +} + +// BackupShortTermRetentionPolicyProperties properties of a short term retention policy +type BackupShortTermRetentionPolicyProperties struct { + // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + +// Database a database resource. +type Database struct { + autorest.Response `json:"-"` + // Sku - The database SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or one of the following commands: + // + // ```azurecli + // az sql db list-editions -l -o table + // ```` + // + // ```powershell + // Get-AzSqlServerServiceObjective -Location + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of database. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedBy - READ-ONLY; Resource that manages the database. + ManagedBy *string `json:"managedBy,omitempty"` + // DatabaseProperties - Resource properties. + *DatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.Sku != nil { + objectMap["sku"] = d.Sku + } + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + d.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + d.Kind = &kind + } + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + d.ManagedBy = &managedBy + } + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseListResult a list of databases. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Database `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseListResult. +func (dlr DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// NextWithContext 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 *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListResultIterator) 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 DatabaseListResultIterator) Response() DatabaseListResult { + 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 DatabaseListResultIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListResultIterator type. +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return DatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DatabaseListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(context.Context, DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// NextWithContext 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 *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dlr) + if err != nil { + return err + } + page.dlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListResultPage) Response() DatabaseListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListResultPage) Values() []Database { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DatabaseListResultPage type. +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return DatabaseListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// DatabaseOperation a database operation. +type DatabaseOperation struct { + // DatabaseOperationProperties - Resource properties. + *DatabaseOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperation. +func (do DatabaseOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if do.DatabaseOperationProperties != nil { + objectMap["properties"] = do.DatabaseOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseOperation struct. +func (do *DatabaseOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseOperationProperties DatabaseOperationProperties + err = json.Unmarshal(*v, &databaseOperationProperties) + if err != nil { + return err + } + do.DatabaseOperationProperties = &databaseOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + do.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + do.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + do.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseOperationListResult the response to a list database operations request +type DatabaseOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperationListResult. +func (dolr DatabaseOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseOperationListResultIterator provides access to a complete listing of DatabaseOperation values. +type DatabaseOperationListResultIterator struct { + i int + page DatabaseOperationListResultPage +} + +// NextWithContext 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 *DatabaseOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseOperationListResultIterator) 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 DatabaseOperationListResultIterator) Response() DatabaseOperationListResult { + 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 DatabaseOperationListResultIterator) Value() DatabaseOperation { + if !iter.page.NotDone() { + return DatabaseOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseOperationListResultIterator type. +func NewDatabaseOperationListResultIterator(page DatabaseOperationListResultPage) DatabaseOperationListResultIterator { + return DatabaseOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dolr DatabaseOperationListResult) IsEmpty() bool { + return dolr.Value == nil || len(*dolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dolr DatabaseOperationListResult) hasNextLink() bool { + return dolr.NextLink != nil && len(*dolr.NextLink) != 0 +} + +// databaseOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dolr DatabaseOperationListResult) databaseOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dolr.NextLink))) +} + +// DatabaseOperationListResultPage contains a page of DatabaseOperation values. +type DatabaseOperationListResultPage struct { + fn func(context.Context, DatabaseOperationListResult) (DatabaseOperationListResult, error) + dolr DatabaseOperationListResult +} + +// NextWithContext 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 *DatabaseOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dolr) + if err != nil { + return err + } + page.dolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseOperationListResultPage) NotDone() bool { + return !page.dolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseOperationListResultPage) Response() DatabaseOperationListResult { + return page.dolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseOperationListResultPage) Values() []DatabaseOperation { + if page.dolr.IsEmpty() { + return nil + } + return *page.dolr.Value +} + +// Creates a new instance of the DatabaseOperationListResultPage type. +func NewDatabaseOperationListResultPage(cur DatabaseOperationListResult, getNextPage func(context.Context, DatabaseOperationListResult) (DatabaseOperationListResult, error)) DatabaseOperationListResultPage { + return DatabaseOperationListResultPage{ + fn: getNextPage, + dolr: cur, + } +} + +// DatabaseOperationProperties the properties of a database operation. +type DatabaseOperationProperties struct { + // DatabaseName - READ-ONLY; The name of the database the operation is being performed on. + DatabaseName *string `json:"databaseName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'Pending', 'InProgress', 'Succeeded', 'Failed', 'CancelInProgress', 'Cancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperationProperties. +func (dop DatabaseOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseProperties the database's properties. +type DatabaseProperties struct { + // CreateMode - Specifies the mode of database creation. + // + // Default: regular database creation. + // + // Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database. + // + // Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database. + // + // PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified. + // + // 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, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'CreateModeDefault', 'CreateModeCopy', 'CreateModeSecondary', 'CreateModePointInTimeRestore', 'CreateModeRestore', 'CreateModeRecovery', 'CreateModeRestoreExternalBackup', 'CreateModeRestoreExternalBackupSecondary', 'CreateModeRestoreLongTermRetentionBackup', 'CreateModeOnlineSecondary' + CreateMode CreateMode `json:"createMode,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` + // MaxSizeBytes - The max size of the database expressed in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // SampleName - The name of the sample schema to apply when creating this database. Possible values include: 'AdventureWorksLT', 'WideWorldImportersStd', 'WideWorldImportersFull' + SampleName SampleName `json:"sampleName,omitempty"` + // ElasticPoolID - The resource identifier of the elastic pool containing this database. + ElasticPoolID *string `json:"elasticPoolId,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled' + Status DatabaseStatus `json:"status,omitempty"` + // DatabaseID - READ-ONLY; The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // CurrentServiceObjectiveName - READ-ONLY; The current service level objective name of the database. + CurrentServiceObjectiveName *string `json:"currentServiceObjectiveName,omitempty"` + // RequestedServiceObjectiveName - READ-ONLY; The requested service level objective name of the database. + RequestedServiceObjectiveName *string `json:"requestedServiceObjectiveName,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // FailoverGroupID - READ-ONLY; Failover Group resource identifier that this database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // SourceDatabaseDeletionDate - Specifies the time that the database was deleted. + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + // RecoveryServicesRecoveryPointID - The resource identifier of the recovery point associated with create operation of this database. + RecoveryServicesRecoveryPointID *string `json:"recoveryServicesRecoveryPointId,omitempty"` + // LongTermRetentionBackupResourceID - The resource identifier of the long term retention backup associated with create operation of this database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The resource identifier of the restorable dropped database associated with create operation of this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'DATABASEDEFAULT', 'SQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // ZoneRedundant - Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this database. `LicenseIncluded` if you need a license, or `BasePrice` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: 'LicenseIncluded', 'BasePrice' + LicenseType DatabaseLicenseType `json:"licenseType,omitempty"` + // MaxLogSizeBytes - READ-ONLY; The max log size for this database. + MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` + // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // ReadScale - If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica. This property is only settable for Premium and Business Critical databases. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' + ReadScale DatabaseReadScale `json:"readScale,omitempty"` + // ReadReplicaCount - The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed. This property is only settable for Hyperscale edition databases. + ReadReplicaCount *int32 `json:"readReplicaCount,omitempty"` + // CurrentSku - READ-ONLY; The name and tier of the SKU. + CurrentSku *Sku `json:"currentSku,omitempty"` + // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled + AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` + // MinCapacity - Minimal capacity that database will always have allocated, if not paused + MinCapacity *float64 `json:"minCapacity,omitempty"` + // PausedDate - READ-ONLY; The date when database was paused by user configuration or action (ISO8601 format). Null if the database is ready. + PausedDate *date.Time `json:"pausedDate,omitempty"` + // ResumedDate - READ-ONLY; The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. + ResumedDate *date.Time `json:"resumedDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseProperties. +func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.CreateMode != "" { + objectMap["createMode"] = dp.CreateMode + } + if dp.Collation != nil { + objectMap["collation"] = dp.Collation + } + if dp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = dp.MaxSizeBytes + } + if dp.SampleName != "" { + objectMap["sampleName"] = dp.SampleName + } + if dp.ElasticPoolID != nil { + objectMap["elasticPoolId"] = dp.ElasticPoolID + } + if dp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = dp.SourceDatabaseID + } + if dp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = dp.RestorePointInTime + } + if dp.SourceDatabaseDeletionDate != nil { + objectMap["sourceDatabaseDeletionDate"] = dp.SourceDatabaseDeletionDate + } + if dp.RecoveryServicesRecoveryPointID != nil { + objectMap["recoveryServicesRecoveryPointId"] = dp.RecoveryServicesRecoveryPointID + } + if dp.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = dp.LongTermRetentionBackupResourceID + } + if dp.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = dp.RecoverableDatabaseID + } + if dp.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = dp.RestorableDroppedDatabaseID + } + if dp.CatalogCollation != "" { + objectMap["catalogCollation"] = dp.CatalogCollation + } + if dp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = dp.ZoneRedundant + } + if dp.LicenseType != "" { + objectMap["licenseType"] = dp.LicenseType + } + if dp.ReadScale != "" { + objectMap["readScale"] = dp.ReadScale + } + if dp.ReadReplicaCount != nil { + objectMap["readReplicaCount"] = dp.ReadReplicaCount + } + if dp.AutoPauseDelay != nil { + objectMap["autoPauseDelay"] = dp.AutoPauseDelay + } + if dp.MinCapacity != nil { + objectMap["minCapacity"] = dp.MinCapacity + } + return json.Marshal(objectMap) +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesCreateOrUpdateFuture.Result. +func (future *DatabasesCreateOrUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesDeleteFuture.Result. +func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesPauseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesPauseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesPauseFuture.Result. +func (future *DatabasesPauseFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.PauseResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesResumeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesResumeFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesResumeFuture.Result. +func (future *DatabasesResumeFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.ResumeResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpdateFuture.Result. +func (future *DatabasesUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesUpgradeDataWarehouseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabasesUpgradeDataWarehouseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpgradeDataWarehouseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpgradeDataWarehouseFuture.Result. +func (future *DatabasesUpgradeDataWarehouseFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpgradeDataWarehouseFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseUpdate a database resource. +type DatabaseUpdate struct { + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // DatabaseProperties - Resource properties. + *DatabaseProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DatabaseUpdate. +func (du DatabaseUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if du.Sku != nil { + objectMap["sku"] = du.Sku + } + if du.DatabaseProperties != nil { + objectMap["properties"] = du.DatabaseProperties + } + if du.Tags != nil { + objectMap["tags"] = du.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseUpdate struct. +func (du *DatabaseUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + du.Sku = &sku + } + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + du.DatabaseProperties = &databaseProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + du.Tags = tags + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessment a database vulnerability assessment. +type DatabaseVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentProperties - Resource properties. + *DatabaseVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessment. +func (dva DatabaseVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dva.DatabaseVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = dva.DatabaseVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessment struct. +func (dva *DatabaseVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentProperties DatabaseVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentProperties) + if err != nil { + return err + } + dva.DatabaseVulnerabilityAssessmentProperties = &databaseVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dva.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentListResult a list of the database's vulnerability assessments. +type DatabaseVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentListResult. +func (dvalr DatabaseVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// DatabaseVulnerabilityAssessment values. +type DatabaseVulnerabilityAssessmentListResultIterator struct { + i int + page DatabaseVulnerabilityAssessmentListResultPage +} + +// NextWithContext 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 *DatabaseVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseVulnerabilityAssessmentListResultIterator) 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 DatabaseVulnerabilityAssessmentListResultIterator) Response() DatabaseVulnerabilityAssessmentListResult { + 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 DatabaseVulnerabilityAssessmentListResultIterator) Value() DatabaseVulnerabilityAssessment { + if !iter.page.NotDone() { + return DatabaseVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseVulnerabilityAssessmentListResultIterator type. +func NewDatabaseVulnerabilityAssessmentListResultIterator(page DatabaseVulnerabilityAssessmentListResultPage) DatabaseVulnerabilityAssessmentListResultIterator { + return DatabaseVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dvalr DatabaseVulnerabilityAssessmentListResult) IsEmpty() bool { + return dvalr.Value == nil || len(*dvalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dvalr DatabaseVulnerabilityAssessmentListResult) hasNextLink() bool { + return dvalr.NextLink != nil && len(*dvalr.NextLink) != 0 +} + +// databaseVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dvalr DatabaseVulnerabilityAssessmentListResult) databaseVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dvalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dvalr.NextLink))) +} + +// DatabaseVulnerabilityAssessmentListResultPage contains a page of DatabaseVulnerabilityAssessment values. +type DatabaseVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, DatabaseVulnerabilityAssessmentListResult) (DatabaseVulnerabilityAssessmentListResult, error) + dvalr DatabaseVulnerabilityAssessmentListResult +} + +// NextWithContext 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 *DatabaseVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dvalr) + if err != nil { + return err + } + page.dvalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.dvalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseVulnerabilityAssessmentListResultPage) Response() DatabaseVulnerabilityAssessmentListResult { + return page.dvalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseVulnerabilityAssessmentListResultPage) Values() []DatabaseVulnerabilityAssessment { + if page.dvalr.IsEmpty() { + return nil + } + return *page.dvalr.Value +} + +// Creates a new instance of the DatabaseVulnerabilityAssessmentListResultPage type. +func NewDatabaseVulnerabilityAssessmentListResultPage(cur DatabaseVulnerabilityAssessmentListResult, getNextPage func(context.Context, DatabaseVulnerabilityAssessmentListResult) (DatabaseVulnerabilityAssessmentListResult, error)) DatabaseVulnerabilityAssessmentListResultPage { + return DatabaseVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + dvalr: cur, + } +} + +// DatabaseVulnerabilityAssessmentProperties properties of a database Vulnerability Assessment. +type DatabaseVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). It is required if server level vulnerability assessment policy doesn't set + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has read and write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// DatabaseVulnerabilityAssessmentRuleBaseline a database vulnerability assessment rule baseline. +type DatabaseVulnerabilityAssessmentRuleBaseline struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentRuleBaselineProperties - Resource properties. + *DatabaseVulnerabilityAssessmentRuleBaselineProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentRuleBaseline. +func (dvarb DatabaseVulnerabilityAssessmentRuleBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties != nil { + objectMap["properties"] = dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessmentRuleBaseline struct. +func (dvarb *DatabaseVulnerabilityAssessmentRuleBaseline) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentRuleBaselineProperties DatabaseVulnerabilityAssessmentRuleBaselineProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentRuleBaselineProperties) + if err != nil { + return err + } + dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties = &databaseVulnerabilityAssessmentRuleBaselineProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dvarb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dvarb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dvarb.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentRuleBaselineItem properties for an Azure SQL Database Vulnerability +// Assessment rule baseline's result. +type DatabaseVulnerabilityAssessmentRuleBaselineItem struct { + // Result - The rule baseline result + Result *[]string `json:"result,omitempty"` +} + +// DatabaseVulnerabilityAssessmentRuleBaselineProperties properties of a database Vulnerability Assessment +// rule baseline. +type DatabaseVulnerabilityAssessmentRuleBaselineProperties struct { + // BaselineResults - The rule baseline result + BaselineResults *[]DatabaseVulnerabilityAssessmentRuleBaselineItem `json:"baselineResults,omitempty"` +} + +// DatabaseVulnerabilityAssessmentScanExportProperties properties of the export operation's result. +type DatabaseVulnerabilityAssessmentScanExportProperties struct { + // ExportedReportLocation - READ-ONLY; Location of the exported report (e.g. https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). + ExportedReportLocation *string `json:"exportedReportLocation,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentScanExportProperties. +func (dvasep DatabaseVulnerabilityAssessmentScanExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessmentScansExport a database Vulnerability Assessment scan export resource. +type DatabaseVulnerabilityAssessmentScansExport struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentScanExportProperties - Resource properties. + *DatabaseVulnerabilityAssessmentScanExportProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentScansExport. +func (dvase DatabaseVulnerabilityAssessmentScansExport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dvase.DatabaseVulnerabilityAssessmentScanExportProperties != nil { + objectMap["properties"] = dvase.DatabaseVulnerabilityAssessmentScanExportProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessmentScansExport struct. +func (dvase *DatabaseVulnerabilityAssessmentScansExport) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentScanExportProperties DatabaseVulnerabilityAssessmentScanExportProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentScanExportProperties) + if err != nil { + return err + } + dvase.DatabaseVulnerabilityAssessmentScanExportProperties = &databaseVulnerabilityAssessmentScanExportProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dvase.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dvase.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dvase.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type DatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *DatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client DatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return +} + +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - READ-ONLY; The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - READ-ONLY; The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for EditionCapability. +func (ec EditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.Reason != nil { + objectMap["reason"] = ec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPool an elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // Sku - The elastic pool SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or the following command: + // + // ```azurecli + // az sql elastic-pool list-editions -l -o table + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ElasticPoolProperties - Resource properties. + *ElasticPoolProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPool. +func (ep ElasticPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.Sku != nil { + objectMap["sku"] = ep.Sku + } + if ep.ElasticPoolProperties != nil { + objectMap["properties"] = ep.ElasticPoolProperties + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPool struct. +func (ep *ElasticPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ep.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "properties": + if v != nil { + var elasticPoolProperties ElasticPoolProperties + err = json.Unmarshal(*v, &elasticPoolProperties) + if err != nil { + return err + } + ep.ElasticPoolProperties = &elasticPoolProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolEditionCapability the elastic pool edition capability. +type ElasticPoolEditionCapability struct { + // Name - READ-ONLY; The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolPerformanceLevels - READ-ONLY; The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolPerformanceLevels *[]ElasticPoolPerformanceLevelCapability `json:"supportedElasticPoolPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolEditionCapability. +func (epec ElasticPoolEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epec.Reason != nil { + objectMap["reason"] = epec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolListResult the result of an elastic pool list request. +type ElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolListResult. +func (eplr ElasticPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolListResultIterator provides access to a complete listing of ElasticPool values. +type ElasticPoolListResultIterator struct { + i int + page ElasticPoolListResultPage +} + +// NextWithContext 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 *ElasticPoolListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolListResultIterator) 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 ElasticPoolListResultIterator) Response() ElasticPoolListResult { + 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 ElasticPoolListResultIterator) Value() ElasticPool { + if !iter.page.NotDone() { + return ElasticPool{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ElasticPoolListResultIterator type. +func NewElasticPoolListResultIterator(page ElasticPoolListResultPage) ElasticPoolListResultIterator { + return ElasticPoolListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr ElasticPoolListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eplr ElasticPoolListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +} + +// elasticPoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr ElasticPoolListResult) elasticPoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// ElasticPoolListResultPage contains a page of ElasticPool values. +type ElasticPoolListResultPage struct { + fn func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error) + eplr ElasticPoolListResult +} + +// NextWithContext 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 *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eplr) + if err != nil { + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolListResultPage) Response() ElasticPoolListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolListResultPage) Values() []ElasticPool { + if page.eplr.IsEmpty() { + return nil + } + return *page.eplr.Value +} + +// Creates a new instance of the ElasticPoolListResultPage type. +func NewElasticPoolListResultPage(cur ElasticPoolListResult, getNextPage func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error)) ElasticPoolListResultPage { + return ElasticPoolListResultPage{ + fn: getNextPage, + eplr: cur, + } +} + +// ElasticPoolOperation a elastic pool operation. +type ElasticPoolOperation struct { + // ElasticPoolOperationProperties - Resource properties. + *ElasticPoolOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperation. +func (epo ElasticPoolOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epo.ElasticPoolOperationProperties != nil { + objectMap["properties"] = epo.ElasticPoolOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolOperation struct. +func (epo *ElasticPoolOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var elasticPoolOperationProperties ElasticPoolOperationProperties + err = json.Unmarshal(*v, &elasticPoolOperationProperties) + if err != nil { + return err + } + epo.ElasticPoolOperationProperties = &elasticPoolOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epo.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epo.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epo.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolOperationListResult the response to a list elastic pool operations request +type ElasticPoolOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPoolOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperationListResult. +func (epolr ElasticPoolOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolOperationListResultIterator provides access to a complete listing of ElasticPoolOperation +// values. +type ElasticPoolOperationListResultIterator struct { + i int + page ElasticPoolOperationListResultPage +} + +// NextWithContext 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 *ElasticPoolOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolOperationListResultIterator) 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 ElasticPoolOperationListResultIterator) Response() ElasticPoolOperationListResult { + 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 ElasticPoolOperationListResultIterator) Value() ElasticPoolOperation { + if !iter.page.NotDone() { + return ElasticPoolOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ElasticPoolOperationListResultIterator type. +func NewElasticPoolOperationListResultIterator(page ElasticPoolOperationListResultPage) ElasticPoolOperationListResultIterator { + return ElasticPoolOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (epolr ElasticPoolOperationListResult) IsEmpty() bool { + return epolr.Value == nil || len(*epolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (epolr ElasticPoolOperationListResult) hasNextLink() bool { + return epolr.NextLink != nil && len(*epolr.NextLink) != 0 +} + +// elasticPoolOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (epolr ElasticPoolOperationListResult) elasticPoolOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !epolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(epolr.NextLink))) +} + +// ElasticPoolOperationListResultPage contains a page of ElasticPoolOperation values. +type ElasticPoolOperationListResultPage struct { + fn func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error) + epolr ElasticPoolOperationListResult +} + +// NextWithContext 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 *ElasticPoolOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.epolr) + if err != nil { + return err + } + page.epolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolOperationListResultPage) NotDone() bool { + return !page.epolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolOperationListResultPage) Response() ElasticPoolOperationListResult { + return page.epolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolOperationListResultPage) Values() []ElasticPoolOperation { + if page.epolr.IsEmpty() { + return nil + } + return *page.epolr.Value +} + +// Creates a new instance of the ElasticPoolOperationListResultPage type. +func NewElasticPoolOperationListResultPage(cur ElasticPoolOperationListResult, getNextPage func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error)) ElasticPoolOperationListResultPage { + return ElasticPoolOperationListResultPage{ + fn: getNextPage, + epolr: cur, + } +} + +// ElasticPoolOperationProperties the properties of a elastic pool operation. +type ElasticPoolOperationProperties struct { + // ElasticPoolName - READ-ONLY; The name of the elastic pool the operation is being performed on. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. + State *string `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperationProperties. +func (epop ElasticPoolOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMaxPerformanceLevelCapability the max per-database performance level capability. +type ElasticPoolPerDatabaseMaxPerformanceLevelCapability struct { + // Limit - READ-ONLY; The maximum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // SupportedPerDatabaseMinPerformanceLevels - READ-ONLY; The list of supported min database performance levels. + SupportedPerDatabaseMinPerformanceLevels *[]ElasticPoolPerDatabaseMinPerformanceLevelCapability `json:"supportedPerDatabaseMinPerformanceLevels,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMaxPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMaxPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMinPerformanceLevelCapability the minimum per-database performance level +// capability. +type ElasticPoolPerDatabaseMinPerformanceLevelCapability struct { + // Limit - READ-ONLY; The minimum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMinPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMinPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseSettings per database settings of an elastic pool. +type ElasticPoolPerDatabaseSettings struct { + // MinCapacity - The minimum capacity all databases are guaranteed. + MinCapacity *float64 `json:"minCapacity,omitempty"` + // MaxCapacity - The maximum capacity any one database can consume. + MaxCapacity *float64 `json:"maxCapacity,omitempty"` +} + +// ElasticPoolPerformanceLevelCapability the Elastic Pool performance level capability. +type ElasticPoolPerformanceLevelCapability struct { + // PerformanceLevel - READ-ONLY; The performance level for the pool. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // MaxDatabaseCount - READ-ONLY; The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size for this performance level. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - READ-ONLY; The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeRangeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxPerformanceLevels - READ-ONLY; The list of supported per database max performance levels. + SupportedPerDatabaseMaxPerformanceLevels *[]ElasticPoolPerDatabaseMaxPerformanceLevelCapability `json:"supportedPerDatabaseMaxPerformanceLevels,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerformanceLevelCapability. +func (epplc ElasticPoolPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epplc.Reason != nil { + objectMap["reason"] = epplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolProperties properties of an elastic pool +type ElasticPoolProperties struct { + // State - READ-ONLY; The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' + State ElasticPoolState `json:"state,omitempty"` + // CreationDate - READ-ONLY; The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolProperties. +func (epp ElasticPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = epp.MaxSizeBytes + } + if epp.PerDatabaseSettings != nil { + objectMap["perDatabaseSettings"] = epp.PerDatabaseSettings + } + if epp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = epp.ZoneRedundant + } + if epp.LicenseType != "" { + objectMap["licenseType"] = epp.LicenseType + } + return json.Marshal(objectMap) +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsCreateOrUpdateFuture.Result. +func (future *ElasticPoolsCreateOrUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsDeleteFuture.Result. +func (future *ElasticPoolsDeleteFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsUpdateFuture.Result. +func (future *ElasticPoolsUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.UpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolUpdate an elastic pool update. +type ElasticPoolUpdate struct { + Sku *Sku `json:"sku,omitempty"` + // ElasticPoolUpdateProperties - Resource properties. + *ElasticPoolUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolUpdate. +func (epu ElasticPoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epu.Sku != nil { + objectMap["sku"] = epu.Sku + } + if epu.ElasticPoolUpdateProperties != nil { + objectMap["properties"] = epu.ElasticPoolUpdateProperties + } + if epu.Tags != nil { + objectMap["tags"] = epu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolUpdate struct. +func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + epu.Sku = &sku + } + case "properties": + if v != nil { + var elasticPoolUpdateProperties ElasticPoolUpdateProperties + err = json.Unmarshal(*v, &elasticPoolUpdateProperties) + if err != nil { + return err + } + epu.ElasticPoolUpdateProperties = &elasticPoolUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + epu.Tags = tags + } + } + } + + return nil +} + +// ElasticPoolUpdateProperties properties of an elastic pool +type ElasticPoolUpdateProperties struct { + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` +} + +// InstanceFailoverGroup an instance failover group. +type InstanceFailoverGroup struct { + autorest.Response `json:"-"` + // InstanceFailoverGroupProperties - Resource properties. + *InstanceFailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroup. +func (ifg InstanceFailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifg.InstanceFailoverGroupProperties != nil { + objectMap["properties"] = ifg.InstanceFailoverGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InstanceFailoverGroup struct. +func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var instanceFailoverGroupProperties InstanceFailoverGroupProperties + err = json.Unmarshal(*v, &instanceFailoverGroupProperties) + if err != nil { + return err + } + ifg.InstanceFailoverGroupProperties = &instanceFailoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ifg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ifg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ifg.Type = &typeVar + } + } + } + + return nil +} + +// InstanceFailoverGroupListResult a list of instance failover groups. +type InstanceFailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstanceFailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupListResult. +func (ifglr InstanceFailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup +// values. +type InstanceFailoverGroupListResultIterator struct { + i int + page InstanceFailoverGroupListResultPage +} + +// NextWithContext 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 *InstanceFailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstanceFailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstanceFailoverGroupListResultIterator) 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 InstanceFailoverGroupListResultIterator) Response() InstanceFailoverGroupListResult { + 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 InstanceFailoverGroupListResultIterator) Value() InstanceFailoverGroup { + if !iter.page.NotDone() { + return InstanceFailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstanceFailoverGroupListResultIterator type. +func NewInstanceFailoverGroupListResultIterator(page InstanceFailoverGroupListResultPage) InstanceFailoverGroupListResultIterator { + return InstanceFailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { + return ifglr.Value == nil || len(*ifglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ifglr InstanceFailoverGroupListResult) hasNextLink() bool { + return ifglr.NextLink != nil && len(*ifglr.NextLink) != 0 +} + +// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ifglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ifglr.NextLink))) +} + +// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultPage struct { + fn func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) + ifglr InstanceFailoverGroupListResult +} + +// NextWithContext 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 *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ifglr) + if err != nil { + return err + } + page.ifglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *InstanceFailoverGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InstanceFailoverGroupListResultPage) NotDone() bool { + return !page.ifglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InstanceFailoverGroupListResultPage) Response() InstanceFailoverGroupListResult { + return page.ifglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InstanceFailoverGroupListResultPage) Values() []InstanceFailoverGroup { + if page.ifglr.IsEmpty() { + return nil + } + return *page.ifglr.Value +} + +// Creates a new instance of the InstanceFailoverGroupListResultPage type. +func NewInstanceFailoverGroupListResultPage(cur InstanceFailoverGroupListResult, getNextPage func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error)) InstanceFailoverGroupListResultPage { + return InstanceFailoverGroupListResultPage{ + fn: getNextPage, + ifglr: cur, + } +} + +// InstanceFailoverGroupProperties properties of a instance failover group. +type InstanceFailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *InstanceFailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *InstanceFailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerRegions - Partner region information for the failover group. + PartnerRegions *[]PartnerRegionInfo `json:"partnerRegions,omitempty"` + // ManagedInstancePairs - List of managed instance pairs in the failover group. + ManagedInstancePairs *[]ManagedInstancePairInfo `json:"managedInstancePairs,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupProperties. +func (ifgp InstanceFailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = ifgp.ReadWriteEndpoint + } + if ifgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = ifgp.ReadOnlyEndpoint + } + if ifgp.PartnerRegions != nil { + objectMap["partnerRegions"] = ifgp.PartnerRegions + } + if ifgp.ManagedInstancePairs != nil { + objectMap["managedInstancePairs"] = ifgp.ManagedInstancePairs + } + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type InstanceFailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// InstanceFailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type InstanceFailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'Manual', 'Automatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// InstanceFailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsCreateOrUpdateFuture.Result. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.CreateOrUpdateResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsDeleteFuture.Result. +func (future *InstanceFailoverGroupsDeleteFuture) result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsFailoverFuture.Result. +func (future *InstanceFailoverGroupsFailoverFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.FailoverResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.ForceFailoverAllowDataLossResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// LicenseTypeCapability the license type capability +type LicenseTypeCapability struct { + // Name - READ-ONLY; License type identifier. + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LicenseTypeCapability. +func (ltc LicenseTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltc.Reason != nil { + objectMap["reason"] = ltc.Reason + } + return json.Marshal(objectMap) +} + +// LocationCapabilities the location capability. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedManagedInstanceVersions - READ-ONLY; The list of supported managed instance versions. + SupportedManagedInstanceVersions *[]ManagedInstanceVersionCapability `json:"supportedManagedInstanceVersions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationCapabilities. +func (lc LocationCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lc.Reason != nil { + objectMap["reason"] = lc.Reason + } + return json.Marshal(objectMap) +} + +// LogSizeCapability the log size capability. +type LogSizeCapability struct { + // Limit - READ-ONLY; The log size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes', 'Percent' + Unit LogSizeUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSizeCapability. +func (lsc LogSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client ManagedDatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceEditionCapability the managed server capability +type ManagedInstanceEditionCapability struct { + // Name - READ-ONLY; The managed server version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]ManagedInstanceFamilyCapability `json:"supportedFamilies,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEditionCapability. +func (miec ManagedInstanceEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miec.Reason != nil { + objectMap["reason"] = miec.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtector the managed instance encryption protector. +type ManagedInstanceEncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceEncryptionProtectorProperties - Resource properties. + *ManagedInstanceEncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtector. +func (miep ManagedInstanceEncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miep.ManagedInstanceEncryptionProtectorProperties != nil { + objectMap["properties"] = miep.ManagedInstanceEncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceEncryptionProtector struct. +func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + miep.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceEncryptionProtectorProperties ManagedInstanceEncryptionProtectorProperties + err = json.Unmarshal(*v, &managedInstanceEncryptionProtectorProperties) + if err != nil { + return err + } + miep.ManagedInstanceEncryptionProtectorProperties = &managedInstanceEncryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miep.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceEncryptionProtectorListResult a list of managed instance encryption protectors. +type ManagedInstanceEncryptionProtectorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceEncryptionProtector `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorListResult. +func (mieplr ManagedInstanceEncryptionProtectorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtectorListResultIterator provides access to a complete listing of +// ManagedInstanceEncryptionProtector values. +type ManagedInstanceEncryptionProtectorListResultIterator struct { + i int + page ManagedInstanceEncryptionProtectorListResultPage +} + +// NextWithContext 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 *ManagedInstanceEncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceEncryptionProtectorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceEncryptionProtectorListResultIterator) 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 ManagedInstanceEncryptionProtectorListResultIterator) Response() ManagedInstanceEncryptionProtectorListResult { + 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 ManagedInstanceEncryptionProtectorListResultIterator) Value() ManagedInstanceEncryptionProtector { + if !iter.page.NotDone() { + return ManagedInstanceEncryptionProtector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultIterator type. +func NewManagedInstanceEncryptionProtectorListResultIterator(page ManagedInstanceEncryptionProtectorListResultPage) ManagedInstanceEncryptionProtectorListResultIterator { + return ManagedInstanceEncryptionProtectorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mieplr ManagedInstanceEncryptionProtectorListResult) IsEmpty() bool { + return mieplr.Value == nil || len(*mieplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mieplr ManagedInstanceEncryptionProtectorListResult) hasNextLink() bool { + return mieplr.NextLink != nil && len(*mieplr.NextLink) != 0 +} + +// managedInstanceEncryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mieplr ManagedInstanceEncryptionProtectorListResult) managedInstanceEncryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mieplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mieplr.NextLink))) +} + +// ManagedInstanceEncryptionProtectorListResultPage contains a page of ManagedInstanceEncryptionProtector +// values. +type ManagedInstanceEncryptionProtectorListResultPage struct { + fn func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error) + mieplr ManagedInstanceEncryptionProtectorListResult +} + +// NextWithContext 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 *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mieplr) + if err != nil { + return err + } + page.mieplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceEncryptionProtectorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceEncryptionProtectorListResultPage) NotDone() bool { + return !page.mieplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceEncryptionProtectorListResultPage) Response() ManagedInstanceEncryptionProtectorListResult { + return page.mieplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceEncryptionProtectorListResultPage) Values() []ManagedInstanceEncryptionProtector { + if page.mieplr.IsEmpty() { + return nil + } + return *page.mieplr.Value +} + +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultPage type. +func NewManagedInstanceEncryptionProtectorListResultPage(cur ManagedInstanceEncryptionProtectorListResult, getNextPage func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error)) ManagedInstanceEncryptionProtectorListResultPage { + return ManagedInstanceEncryptionProtectorListResultPage{ + fn: getNextPage, + mieplr: cur, + } +} + +// ManagedInstanceEncryptionProtectorProperties properties for an encryption protector execution. +type ManagedInstanceEncryptionProtectorProperties struct { + // ServerKeyName - The name of the managed instance key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorProperties. +func (miepp ManagedInstanceEncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miepp.ServerKeyName != nil { + objectMap["serverKeyName"] = miepp.ServerKeyName + } + if miepp.ServerKeyType != "" { + objectMap["serverKeyType"] = miepp.ServerKeyType + } + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (ManagedInstanceEncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (miep ManagedInstanceEncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miep.Response.Response, err = future.GetResult(sender); err == nil && miep.Response.Response.StatusCode != http.StatusNoContent { + miep, err = client.CreateOrUpdateResponder(miep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", miep.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceEncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsRevalidateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceFamilyCapability the managed server family capability. +type ManagedInstanceFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // Sku - READ-ONLY; SKU name. + Sku *string `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]ManagedInstanceVcoresCapability `json:"supportedVcoresValues,omitempty"` + // IncludedMaxSize - READ-ONLY; Included size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedStorageSizes - READ-ONLY; Storage size ranges. + SupportedStorageSizes *[]MaxSizeRangeCapability `json:"supportedStorageSizes,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceFamilyCapability. +func (mifc ManagedInstanceFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mifc.Reason != nil { + objectMap["reason"] = mifc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKey a managed instance key. +type ManagedInstanceKey struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceKeyProperties - Resource properties. + *ManagedInstanceKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKey. +func (mik ManagedInstanceKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mik.ManagedInstanceKeyProperties != nil { + objectMap["properties"] = mik.ManagedInstanceKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceKey struct. +func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mik.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceKeyProperties ManagedInstanceKeyProperties + err = json.Unmarshal(*v, &managedInstanceKeyProperties) + if err != nil { + return err + } + mik.ManagedInstanceKeyProperties = &managedInstanceKeyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mik.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mik.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mik.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceKeyListResult a list of managed instance keys. +type ManagedInstanceKeyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceKey `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKeyListResult. +func (miklr ManagedInstanceKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceKeyListResultIterator provides access to a complete listing of ManagedInstanceKey values. +type ManagedInstanceKeyListResultIterator struct { + i int + page ManagedInstanceKeyListResultPage +} + +// NextWithContext 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 *ManagedInstanceKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceKeyListResultIterator) 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 ManagedInstanceKeyListResultIterator) Response() ManagedInstanceKeyListResult { + 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 ManagedInstanceKeyListResultIterator) Value() ManagedInstanceKey { + if !iter.page.NotDone() { + return ManagedInstanceKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceKeyListResultIterator type. +func NewManagedInstanceKeyListResultIterator(page ManagedInstanceKeyListResultPage) ManagedInstanceKeyListResultIterator { + return ManagedInstanceKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miklr ManagedInstanceKeyListResult) IsEmpty() bool { + return miklr.Value == nil || len(*miklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miklr ManagedInstanceKeyListResult) hasNextLink() bool { + return miklr.NextLink != nil && len(*miklr.NextLink) != 0 +} + +// managedInstanceKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miklr ManagedInstanceKeyListResult) managedInstanceKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miklr.NextLink))) +} + +// ManagedInstanceKeyListResultPage contains a page of ManagedInstanceKey values. +type ManagedInstanceKeyListResultPage struct { + fn func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error) + miklr ManagedInstanceKeyListResult +} + +// NextWithContext 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 *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miklr) + if err != nil { + return err + } + page.miklr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceKeyListResultPage) NotDone() bool { + return !page.miklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceKeyListResultPage) Response() ManagedInstanceKeyListResult { + return page.miklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceKeyListResultPage) Values() []ManagedInstanceKey { + if page.miklr.IsEmpty() { + return nil + } + return *page.miklr.Value +} + +// Creates a new instance of the ManagedInstanceKeyListResultPage type. +func NewManagedInstanceKeyListResultPage(cur ManagedInstanceKeyListResult, getNextPage func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error)) ManagedInstanceKeyListResultPage { + return ManagedInstanceKeyListResultPage{ + fn: getNextPage, + miklr: cur, + } +} + +// ManagedInstanceKeyProperties properties for a key execution. +type ManagedInstanceKeyProperties struct { + // ServerKeyType - The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - READ-ONLY; The key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKeyProperties. +func (mikp ManagedInstanceKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mikp.ServerKeyType != "" { + objectMap["serverKeyType"] = mikp.ServerKeyType + } + if mikp.URI != nil { + objectMap["uri"] = mikp.URI + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (ManagedInstanceKey, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceKeysCreateOrUpdateFuture.Result. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) result(client ManagedInstanceKeysClient) (mik ManagedInstanceKey, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mik.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mik.Response.Response, err = future.GetResult(sender); err == nil && mik.Response.Response.StatusCode != http.StatusNoContent { + mik, err = client.CreateOrUpdateResponder(mik.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", mik.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceKeysDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceKeysDeleteFuture.Result. +func (future *ManagedInstanceKeysDeleteFuture) result(client ManagedInstanceKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancePairInfo pairs of Managed Instances in the failover group. +type ManagedInstancePairInfo struct { + // PrimaryManagedInstanceID - Id of Primary Managed Instance in pair. + PrimaryManagedInstanceID *string `json:"primaryManagedInstanceId,omitempty"` + // PartnerManagedInstanceID - Id of Partner Managed Instance in pair. + PartnerManagedInstanceID *string `json:"partnerManagedInstanceId,omitempty"` +} + +// ManagedInstanceTdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceTdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceTdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceTdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceTdeCertificatesCreateFuture.Result. +func (future *ManagedInstanceTdeCertificatesCreateFuture) result(client ManagedInstanceTdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceTdeCertificatesCreateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceVcoresCapability the managed instance virtual cores capability. +type ManagedInstanceVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVcoresCapability. +func (mivc ManagedInstanceVcoresCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceVersionCapability the managed instance capability +type ManagedInstanceVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported managed instance editions. + SupportedEditions *[]ManagedInstanceEditionCapability `json:"supportedEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVersionCapability. +func (mivc ManagedInstanceVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason + } + return json.Marshal(objectMap) +} + +// MaxSizeCapability the maximum size capability. +type MaxSizeCapability struct { + // Limit - READ-ONLY; The maximum size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'MaxSizeUnitMegabytes', 'MaxSizeUnitGigabytes', 'MaxSizeUnitTerabytes', 'MaxSizeUnitPetabytes' + Unit MaxSizeUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeCapability. +func (msc MaxSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MaxSizeRangeCapability the maximum size range capability. +type MaxSizeRangeCapability struct { + // MinValue - READ-ONLY; Minimum value. + MinValue *MaxSizeCapability `json:"minValue,omitempty"` + // MaxValue - READ-ONLY; Maximum value. + MaxValue *MaxSizeCapability `json:"maxValue,omitempty"` + // ScaleSize - READ-ONLY; Scale/step size for discrete values between the minimum value and the maximum value. + ScaleSize *MaxSizeCapability `json:"scaleSize,omitempty"` + // LogSize - READ-ONLY; Size of transaction log. + LogSize *LogSizeCapability `json:"logSize,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeRangeCapability. +func (msrc MaxSizeRangeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if msrc.Reason != nil { + objectMap["reason"] = msrc.Reason + } + return json.Marshal(objectMap) +} + +// PartnerRegionInfo partner region information for the failover group. +type PartnerRegionInfo struct { + // Location - Geo location of the partner managed instances. + Location *string `json:"location,omitempty"` + // ReplicationRole - READ-ONLY; Replication role of the partner managed instances. Possible values include: 'Primary', 'Secondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartnerRegionInfo. +func (pri PartnerRegionInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pri.Location != nil { + objectMap["location"] = pri.Location + } + return json.Marshal(objectMap) +} + +// PerformanceLevelCapability the performance level capability. +type PerformanceLevelCapability struct { + // Value - READ-ONLY; Performance level value. + Value *float64 `json:"value,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for PerformanceLevelCapability. +func (plc PerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableManagedDatabase a recoverable managed database resource. +type RecoverableManagedDatabase struct { + autorest.Response `json:"-"` + // RecoverableManagedDatabaseProperties - Resource properties. + *RecoverableManagedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabase. +func (rmd RecoverableManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmd.RecoverableManagedDatabaseProperties != nil { + objectMap["properties"] = rmd.RecoverableManagedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableManagedDatabase struct. +func (rmd *RecoverableManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recoverableManagedDatabaseProperties RecoverableManagedDatabaseProperties + err = json.Unmarshal(*v, &recoverableManagedDatabaseProperties) + if err != nil { + return err + } + rmd.RecoverableManagedDatabaseProperties = &recoverableManagedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmd.Type = &typeVar + } + } + } + + return nil +} + +// RecoverableManagedDatabaseListResult a list of recoverable managed databases. +type RecoverableManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RecoverableManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabaseListResult. +func (rmdlr RecoverableManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableManagedDatabaseListResultIterator provides access to a complete listing of +// RecoverableManagedDatabase values. +type RecoverableManagedDatabaseListResultIterator struct { + i int + page RecoverableManagedDatabaseListResultPage +} + +// NextWithContext 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 *RecoverableManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RecoverableManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RecoverableManagedDatabaseListResultIterator) 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 RecoverableManagedDatabaseListResultIterator) Response() RecoverableManagedDatabaseListResult { + 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 RecoverableManagedDatabaseListResultIterator) Value() RecoverableManagedDatabase { + if !iter.page.NotDone() { + return RecoverableManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RecoverableManagedDatabaseListResultIterator type. +func NewRecoverableManagedDatabaseListResultIterator(page RecoverableManagedDatabaseListResultPage) RecoverableManagedDatabaseListResultIterator { + return RecoverableManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rmdlr RecoverableManagedDatabaseListResult) IsEmpty() bool { + return rmdlr.Value == nil || len(*rmdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rmdlr RecoverableManagedDatabaseListResult) hasNextLink() bool { + return rmdlr.NextLink != nil && len(*rmdlr.NextLink) != 0 +} + +// recoverableManagedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rmdlr RecoverableManagedDatabaseListResult) recoverableManagedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rmdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rmdlr.NextLink))) +} + +// RecoverableManagedDatabaseListResultPage contains a page of RecoverableManagedDatabase values. +type RecoverableManagedDatabaseListResultPage struct { + fn func(context.Context, RecoverableManagedDatabaseListResult) (RecoverableManagedDatabaseListResult, error) + rmdlr RecoverableManagedDatabaseListResult +} + +// NextWithContext 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 *RecoverableManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rmdlr) + if err != nil { + return err + } + page.rmdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *RecoverableManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RecoverableManagedDatabaseListResultPage) NotDone() bool { + return !page.rmdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RecoverableManagedDatabaseListResultPage) Response() RecoverableManagedDatabaseListResult { + return page.rmdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RecoverableManagedDatabaseListResultPage) Values() []RecoverableManagedDatabase { + if page.rmdlr.IsEmpty() { + return nil + } + return *page.rmdlr.Value +} + +// Creates a new instance of the RecoverableManagedDatabaseListResultPage type. +func NewRecoverableManagedDatabaseListResultPage(cur RecoverableManagedDatabaseListResult, getNextPage func(context.Context, RecoverableManagedDatabaseListResult) (RecoverableManagedDatabaseListResult, error)) RecoverableManagedDatabaseListResultPage { + return RecoverableManagedDatabaseListResultPage{ + fn: getNextPage, + rmdlr: cur, + } +} + +// RecoverableManagedDatabaseProperties the recoverable managed database's properties. +type RecoverableManagedDatabaseProperties struct { + // LastAvailableBackupDate - READ-ONLY; The last available backup date. + LastAvailableBackupDate *string `json:"lastAvailableBackupDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabaseProperties. +func (rmdp RecoverableManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource ARM resource. +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceMoveDefinition contains the information necessary to perform a resource move (rename). +type ResourceMoveDefinition struct { + // ID - The target ID for the resource + ID *string `json:"id,omitempty"` +} + +// ServerVersionCapability the server capability +type ServerVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - READ-ONLY; The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if svc.Reason != nil { + objectMap["reason"] = svc.Reason + } + return json.Marshal(objectMap) +} + +// ServiceObjectiveCapability the service objectives capability. +type ServiceObjectiveCapability struct { + // ID - READ-ONLY; The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // Name - READ-ONLY; The service objective name. + Name *string `json:"name,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported maximum database sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // PerformanceLevel - READ-ONLY; The performance level. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'Visible', 'Available', 'Default', 'Disabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveCapability. +func (soc ServiceObjectiveCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if soc.Reason != nil { + objectMap["reason"] = soc.Reason + } + return json.Marshal(objectMap) +} + +// Sku an ARM Resource SKU. +type Sku struct { + // Name - The name of the SKU, typically, a letter + Number code, e.g. P3. + Name *string `json:"name,omitempty"` + // Tier - The tier or edition of the particular SKU, e.g. Basic, Premium. + Tier *string `json:"tier,omitempty"` + // Size - Size of the particular SKU + Size *string `json:"size,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // Capacity - Capacity of the particular SKU. + Capacity *int32 `json:"capacity,omitempty"` +} + +// TdeCertificate a TDE certificate that can be uploaded into a server. +type TdeCertificate struct { + // TdeCertificateProperties - Resource properties. + *TdeCertificateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TdeCertificate. +func (tc TdeCertificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tc.TdeCertificateProperties != nil { + objectMap["properties"] = tc.TdeCertificateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TdeCertificate struct. +func (tc *TdeCertificate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tdeCertificateProperties TdeCertificateProperties + err = json.Unmarshal(*v, &tdeCertificateProperties) + if err != nil { + return err + } + tc.TdeCertificateProperties = &tdeCertificateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tc.Type = &typeVar + } + } + } + + return nil +} + +// TdeCertificateProperties properties of a TDE certificate. +type TdeCertificateProperties struct { + // PrivateBlob - The base64 encoded certificate private blob. + PrivateBlob *string `json:"privateBlob,omitempty"` + // CertPassword - The certificate password. + CertPassword *string `json:"certPassword,omitempty"` +} + +// TdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type TdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TdeCertificatesCreateFuture.Result. +func (future *TdeCertificatesCreateFuture) result(client TdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.TdeCertificatesCreateFuture") + return + } + ar.Response = future.Response() + return +} + +// TrackedResource ARM tracked top level resource. +type TrackedResource struct { + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentRecurringScansProperties properties of a Vulnerability Assessment recurring +// scans. +type VulnerabilityAssessmentRecurringScansProperties struct { + // IsEnabled - Recurring scans state. + IsEnabled *bool `json:"isEnabled,omitempty"` + // EmailSubscriptionAdmins - Specifies that the schedule scan notification will be is sent to the subscription administrators. + EmailSubscriptionAdmins *bool `json:"emailSubscriptionAdmins,omitempty"` + // Emails - Specifies an array of e-mail addresses to which the scan notification is sent. + Emails *[]string `json:"emails,omitempty"` +} + +// VulnerabilityAssessmentScanError properties of a vulnerability assessment scan error. +type VulnerabilityAssessmentScanError struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanError. +func (vase VulnerabilityAssessmentScanError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentScanRecord a vulnerability assessment scan record. +type VulnerabilityAssessmentScanRecord struct { + autorest.Response `json:"-"` + // VulnerabilityAssessmentScanRecordProperties - Resource properties. + *VulnerabilityAssessmentScanRecordProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecord. +func (vasr VulnerabilityAssessmentScanRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vasr.VulnerabilityAssessmentScanRecordProperties != nil { + objectMap["properties"] = vasr.VulnerabilityAssessmentScanRecordProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VulnerabilityAssessmentScanRecord struct. +func (vasr *VulnerabilityAssessmentScanRecord) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var vulnerabilityAssessmentScanRecordProperties VulnerabilityAssessmentScanRecordProperties + err = json.Unmarshal(*v, &vulnerabilityAssessmentScanRecordProperties) + if err != nil { + return err + } + vasr.VulnerabilityAssessmentScanRecordProperties = &vulnerabilityAssessmentScanRecordProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vasr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vasr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vasr.Type = &typeVar + } + } + } + + return nil +} + +// VulnerabilityAssessmentScanRecordListResult a list of vulnerability assessment scan records. +type VulnerabilityAssessmentScanRecordListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VulnerabilityAssessmentScanRecord `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecordListResult. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentScanRecordListResultIterator provides access to a complete listing of +// VulnerabilityAssessmentScanRecord values. +type VulnerabilityAssessmentScanRecordListResultIterator struct { + i int + page VulnerabilityAssessmentScanRecordListResultPage +} + +// NextWithContext 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 *VulnerabilityAssessmentScanRecordListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VulnerabilityAssessmentScanRecordListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VulnerabilityAssessmentScanRecordListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VulnerabilityAssessmentScanRecordListResultIterator) 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 VulnerabilityAssessmentScanRecordListResultIterator) Response() VulnerabilityAssessmentScanRecordListResult { + 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 VulnerabilityAssessmentScanRecordListResultIterator) Value() VulnerabilityAssessmentScanRecord { + if !iter.page.NotDone() { + return VulnerabilityAssessmentScanRecord{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VulnerabilityAssessmentScanRecordListResultIterator type. +func NewVulnerabilityAssessmentScanRecordListResultIterator(page VulnerabilityAssessmentScanRecordListResultPage) VulnerabilityAssessmentScanRecordListResultIterator { + return VulnerabilityAssessmentScanRecordListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) IsEmpty() bool { + return vasrlr.Value == nil || len(*vasrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) hasNextLink() bool { + return vasrlr.NextLink != nil && len(*vasrlr.NextLink) != 0 +} + +// vulnerabilityAssessmentScanRecordListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) vulnerabilityAssessmentScanRecordListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vasrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vasrlr.NextLink))) +} + +// VulnerabilityAssessmentScanRecordListResultPage contains a page of VulnerabilityAssessmentScanRecord +// values. +type VulnerabilityAssessmentScanRecordListResultPage struct { + fn func(context.Context, VulnerabilityAssessmentScanRecordListResult) (VulnerabilityAssessmentScanRecordListResult, error) + vasrlr VulnerabilityAssessmentScanRecordListResult +} + +// NextWithContext 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 *VulnerabilityAssessmentScanRecordListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VulnerabilityAssessmentScanRecordListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vasrlr) + if err != nil { + return err + } + page.vasrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VulnerabilityAssessmentScanRecordListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VulnerabilityAssessmentScanRecordListResultPage) NotDone() bool { + return !page.vasrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VulnerabilityAssessmentScanRecordListResultPage) Response() VulnerabilityAssessmentScanRecordListResult { + return page.vasrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VulnerabilityAssessmentScanRecordListResultPage) Values() []VulnerabilityAssessmentScanRecord { + if page.vasrlr.IsEmpty() { + return nil + } + return *page.vasrlr.Value +} + +// Creates a new instance of the VulnerabilityAssessmentScanRecordListResultPage type. +func NewVulnerabilityAssessmentScanRecordListResultPage(cur VulnerabilityAssessmentScanRecordListResult, getNextPage func(context.Context, VulnerabilityAssessmentScanRecordListResult) (VulnerabilityAssessmentScanRecordListResult, error)) VulnerabilityAssessmentScanRecordListResultPage { + return VulnerabilityAssessmentScanRecordListResultPage{ + fn: getNextPage, + vasrlr: cur, + } +} + +// VulnerabilityAssessmentScanRecordProperties properties of a vulnerability assessment scan record. +type VulnerabilityAssessmentScanRecordProperties struct { + // ScanID - READ-ONLY; The scan ID. + ScanID *string `json:"scanId,omitempty"` + // TriggerType - READ-ONLY; The scan trigger type. Possible values include: 'OnDemand', 'Recurring' + TriggerType VulnerabilityAssessmentScanTriggerType `json:"triggerType,omitempty"` + // State - READ-ONLY; The scan status. Possible values include: 'VulnerabilityAssessmentScanStatePassed', 'VulnerabilityAssessmentScanStateFailed', 'VulnerabilityAssessmentScanStateFailedToRun', 'VulnerabilityAssessmentScanStateInProgress' + State VulnerabilityAssessmentScanState `json:"state,omitempty"` + // StartTime - READ-ONLY; The scan start time (UTC). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The scan end time (UTC). + EndTime *date.Time `json:"endTime,omitempty"` + // Errors - READ-ONLY; The scan errors. + Errors *[]VulnerabilityAssessmentScanError `json:"errors,omitempty"` + // StorageContainerPath - READ-ONLY; The scan results storage container path. + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // NumberOfFailedSecurityChecks - READ-ONLY; The number of failed security checks. + NumberOfFailedSecurityChecks *int32 `json:"numberOfFailedSecurityChecks,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecordProperties. +func (vasrp VulnerabilityAssessmentScanRecordProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/recoverablemanageddatabases.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/recoverablemanageddatabases.go new file mode 100644 index 000000000000..e6519d2d5a1d --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/recoverablemanageddatabases.go @@ -0,0 +1,231 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RecoverableManagedDatabasesClient 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 RecoverableManagedDatabasesClient struct { + BaseClient +} + +// NewRecoverableManagedDatabasesClient creates an instance of the RecoverableManagedDatabasesClient client. +func NewRecoverableManagedDatabasesClient(subscriptionID string) RecoverableManagedDatabasesClient { + return NewRecoverableManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableManagedDatabasesClientWithBaseURI creates an instance of the RecoverableManagedDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRecoverableManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RecoverableManagedDatabasesClient { + return RecoverableManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RecoverableManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (result RecoverableManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, recoverableDatabaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "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.RecoverableManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "recoverableDatabaseName": autorest.Encode("path", recoverableDatabaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}", 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 RecoverableManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableManagedDatabasesClient) GetResponder(resp *http.Response) (result RecoverableManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of recoverable managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RecoverableManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RecoverableManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.rmdlr.Response.Response != nil { + sc = result.rmdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.rmdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.rmdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.rmdlr.hasNextLink() && result.rmdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client RecoverableManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/recoverableDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client RecoverableManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client RecoverableManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result RecoverableManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client RecoverableManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults RecoverableManagedDatabaseListResult) (result RecoverableManagedDatabaseListResult, err error) { + req, err := lastResults.recoverableManagedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecoverableManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RecoverableManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/sqlapi/interfaces.go new file mode 100644 index 000000000000..66060f84d656 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/sqlapi/interfaces.go @@ -0,0 +1,180 @@ +package sqlapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/azure-sdk-for-go/services/preview/sql/mgmt/2017-10-01-preview/sql" + "github.com/Azure/go-autorest/autorest" + "github.com/gofrs/uuid" +) + +// DatabaseOperationsClientAPI contains the set of methods on the DatabaseOperationsClient type. +type DatabaseOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseOperationListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseOperationListResultIterator, err error) +} + +var _ DatabaseOperationsClientAPI = (*sql.DatabaseOperationsClient)(nil) + +// ElasticPoolOperationsClientAPI contains the set of methods on the ElasticPoolOperationsClient type. +type ElasticPoolOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolOperationListResultPage, err error) + ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolOperationListResultIterator, err error) +} + +var _ ElasticPoolOperationsClientAPI = (*sql.ElasticPoolOperationsClient)(nil) + +// DatabaseVulnerabilityAssessmentScansClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentScansClient type. +type DatabaseVulnerabilityAssessmentScansClientAPI interface { + Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansExport, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.VulnerabilityAssessmentScanRecord, err error) + InitiateScan(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultIterator, err error) +} + +var _ DatabaseVulnerabilityAssessmentScansClientAPI = (*sql.DatabaseVulnerabilityAssessmentScansClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient type. +type ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName, parameters sql.DatabaseVulnerabilityAssessmentRuleBaseline) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentScansClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentScansClient type. +type ManagedDatabaseVulnerabilityAssessmentScansClientAPI interface { + Export(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansExport, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.VulnerabilityAssessmentScanRecord, err error) + InitiateScan(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultIterator, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentScansClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentScansClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentsClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentsClient type. +type ManagedDatabaseVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.DatabaseVulnerabilityAssessment) (result sql.DatabaseVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessment, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentsClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentsClient)(nil) + +// CapabilitiesClientAPI contains the set of methods on the CapabilitiesClient type. +type CapabilitiesClientAPI interface { + ListByLocation(ctx context.Context, locationName string, include sql.CapabilityGroup) (result sql.LocationCapabilities, err error) +} + +var _ CapabilitiesClientAPI = (*sql.CapabilitiesClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.Database) (result sql.DatabasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.Database, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResultPage, err error) + ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResultIterator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultIterator, err error) + Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesPauseFuture, err error) + Rename(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ResourceMoveDefinition) (result autorest.Response, err error) + Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesResumeFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseUpdate) (result sql.DatabasesUpdateFuture, err error) + UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesUpgradeDataWarehouseFuture, err error) +} + +var _ DatabasesClientAPI = (*sql.DatabasesClient)(nil) + +// ElasticPoolsClientAPI contains the set of methods on the ElasticPoolsClient type. +type ElasticPoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPool) (result sql.ElasticPoolsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPool, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPoolUpdate) (result sql.ElasticPoolsUpdateFuture, err error) +} + +var _ ElasticPoolsClientAPI = (*sql.ElasticPoolsClient)(nil) + +// InstanceFailoverGroupsClientAPI contains the set of methods on the InstanceFailoverGroupsClient type. +type InstanceFailoverGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters sql.InstanceFailoverGroup) (result sql.InstanceFailoverGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsFailoverFuture, err error) + ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroup, err error) + ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result sql.InstanceFailoverGroupListResultPage, err error) + ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result sql.InstanceFailoverGroupListResultIterator, err error) +} + +var _ InstanceFailoverGroupsClientAPI = (*sql.InstanceFailoverGroupsClient)(nil) + +// BackupShortTermRetentionPoliciesClientAPI contains the set of methods on the BackupShortTermRetentionPoliciesClient type. +type BackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ BackupShortTermRetentionPoliciesClientAPI = (*sql.BackupShortTermRetentionPoliciesClient)(nil) + +// TdeCertificatesClientAPI contains the set of methods on the TdeCertificatesClient type. +type TdeCertificatesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, parameters sql.TdeCertificate) (result sql.TdeCertificatesCreateFuture, err error) +} + +var _ TdeCertificatesClientAPI = (*sql.TdeCertificatesClient)(nil) + +// ManagedInstanceTdeCertificatesClientAPI contains the set of methods on the ManagedInstanceTdeCertificatesClient type. +type ManagedInstanceTdeCertificatesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.TdeCertificate) (result sql.ManagedInstanceTdeCertificatesCreateFuture, err error) +} + +var _ ManagedInstanceTdeCertificatesClientAPI = (*sql.ManagedInstanceTdeCertificatesClient)(nil) + +// ManagedInstanceKeysClientAPI contains the set of methods on the ManagedInstanceKeysClient type. +type ManagedInstanceKeysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters sql.ManagedInstanceKey) (result sql.ManagedInstanceKeysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result sql.ManagedInstanceKeysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result sql.ManagedInstanceKey, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result sql.ManagedInstanceKeyListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result sql.ManagedInstanceKeyListResultIterator, err error) +} + +var _ ManagedInstanceKeysClientAPI = (*sql.ManagedInstanceKeysClient)(nil) + +// ManagedInstanceEncryptionProtectorsClientAPI contains the set of methods on the ManagedInstanceEncryptionProtectorsClient type. +type ManagedInstanceEncryptionProtectorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceEncryptionProtector) (result sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtector, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorListResultIterator, err error) + Revalidate(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) +} + +var _ ManagedInstanceEncryptionProtectorsClientAPI = (*sql.ManagedInstanceEncryptionProtectorsClient)(nil) + +// RecoverableManagedDatabasesClientAPI contains the set of methods on the RecoverableManagedDatabasesClient type. +type RecoverableManagedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (result sql.RecoverableManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RecoverableManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RecoverableManagedDatabaseListResultIterator, err error) +} + +var _ RecoverableManagedDatabasesClientAPI = (*sql.RecoverableManagedDatabasesClient)(nil) diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/tdecertificates.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/tdecertificates.go new file mode 100644 index 000000000000..ab35584ea1b0 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/tdecertificates.go @@ -0,0 +1,123 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TdeCertificatesClient 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 TdeCertificatesClient struct { + BaseClient +} + +// NewTdeCertificatesClient creates an instance of the TdeCertificatesClient client. +func NewTdeCertificatesClient(subscriptionID string) TdeCertificatesClient { + return NewTdeCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTdeCertificatesClientWithBaseURI creates an instance of the TdeCertificatesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTdeCertificatesClientWithBaseURI(baseURI string, subscriptionID string) TdeCertificatesClient { + return TdeCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a TDE certificate for a given server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested TDE certificate to be created or updated. +func (client TdeCertificatesClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters TdeCertificate) (result TdeCertificatesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TdeCertificatesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TdeCertificateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TdeCertificateProperties.PrivateBlob", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.TdeCertificatesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TdeCertificatesClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters TdeCertificate) (*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-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates", pathParameters), + autorest.WithJSON(parameters), + 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 TdeCertificatesClient) CreateSender(req *http.Request) (future TdeCertificatesCreateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TdeCertificatesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/version.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/version.go new file mode 100644 index 000000000000..d0005d2aa511 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/version.go @@ -0,0 +1,19 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " sql/2017-10-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/sql/mgmt/2018-06-01-preview/sql/CHANGELOG.md b/services/preview/sql/mgmt/2018-06-01-preview/sql/CHANGELOG.md index 52911e4cc5e4..71c26d62a517 100644 --- a/services/preview/sql/mgmt/2018-06-01-preview/sql/CHANGELOG.md +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/CHANGELOG.md @@ -1,2 +1,28 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Constants + +1. SensitivityLabelRank.Critical +1. SensitivityLabelRank.High +1. SensitivityLabelRank.Low +1. SensitivityLabelRank.Medium + +### Signature Changes + +#### Const Types + +1. None changed type from SensitivityLabelRank to IdentityType + +## Additive Changes + +### New Constants + +1. IdentityType.SystemAssignedUserAssigned +1. IdentityType.UserAssigned +1. SensitivityLabelRank.SensitivityLabelRankCritical +1. SensitivityLabelRank.SensitivityLabelRankHigh +1. SensitivityLabelRank.SensitivityLabelRankLow +1. SensitivityLabelRank.SensitivityLabelRankMedium +1. SensitivityLabelRank.SensitivityLabelRankNone diff --git a/services/preview/sql/mgmt/2018-06-01-preview/sql/_meta.json b/services/preview/sql/mgmt/2018-06-01-preview/sql/_meta.json index 66cbec1fe487..c05edf6aa149 100644 --- a/services/preview/sql/mgmt/2018-06-01-preview/sql/_meta.json +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", "tag": "package-pure-2018-06-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/sql/mgmt/2018-06-01-preview/sql/enums.go b/services/preview/sql/mgmt/2018-06-01-preview/sql/enums.go index 1202e51a3fa1..612a61848f06 100644 --- a/services/preview/sql/mgmt/2018-06-01-preview/sql/enums.go +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/enums.go @@ -42,13 +42,19 @@ func PossibleDatabaseStateValues() []DatabaseState { type IdentityType string const ( + // None ... + None IdentityType = "None" // SystemAssigned ... SystemAssigned IdentityType = "SystemAssigned" + // SystemAssignedUserAssigned ... + SystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" + // UserAssigned ... + UserAssigned IdentityType = "UserAssigned" ) // PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. func PossibleIdentityTypeValues() []IdentityType { - return []IdentityType{SystemAssigned} + return []IdentityType{None, SystemAssigned, SystemAssignedUserAssigned, UserAssigned} } // InstancePoolLicenseType enumerates the values for instance pool license type. @@ -218,21 +224,21 @@ func PossibleSecurityAlertPolicyStateValues() []SecurityAlertPolicyState { type SensitivityLabelRank string const ( - // Critical ... - Critical SensitivityLabelRank = "Critical" - // High ... - High SensitivityLabelRank = "High" - // Low ... - Low SensitivityLabelRank = "Low" - // Medium ... - Medium SensitivityLabelRank = "Medium" - // None ... - None SensitivityLabelRank = "None" + // SensitivityLabelRankCritical ... + SensitivityLabelRankCritical SensitivityLabelRank = "Critical" + // SensitivityLabelRankHigh ... + SensitivityLabelRankHigh SensitivityLabelRank = "High" + // SensitivityLabelRankLow ... + SensitivityLabelRankLow SensitivityLabelRank = "Low" + // SensitivityLabelRankMedium ... + SensitivityLabelRankMedium SensitivityLabelRank = "Medium" + // SensitivityLabelRankNone ... + SensitivityLabelRankNone SensitivityLabelRank = "None" ) // PossibleSensitivityLabelRankValues returns an array of possible values for the SensitivityLabelRank const type. func PossibleSensitivityLabelRankValues() []SensitivityLabelRank { - return []SensitivityLabelRank{Critical, High, Low, Medium, None} + return []SensitivityLabelRank{SensitivityLabelRankCritical, SensitivityLabelRankHigh, SensitivityLabelRankLow, SensitivityLabelRankMedium, SensitivityLabelRankNone} } // SensitivityLabelSource enumerates the values for sensitivity label source. diff --git a/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go b/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go index 78b6b544489e..83d18bb325c2 100644 --- a/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go @@ -3801,7 +3801,7 @@ func (r Resource) MarshalJSON() ([]byte, error) { type ResourceIdentity struct { // PrincipalID - READ-ONLY; The Azure Active Directory principal id. PrincipalID *uuid.UUID `json:"principalId,omitempty"` - // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'SystemAssigned' + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned' Type IdentityType `json:"type,omitempty"` // TenantID - READ-ONLY; The Azure Active Directory tenant id. TenantID *uuid.UUID `json:"tenantId,omitempty"` @@ -4113,7 +4113,7 @@ type SensitivityLabelProperties struct { InformationTypeID *string `json:"informationTypeId,omitempty"` // IsDisabled - READ-ONLY; Is sensitivity recommendation disabled. Applicable for recommended sensitivity label only. Specifies whether the sensitivity recommendation on this column is disabled (dismissed) or not. IsDisabled *bool `json:"isDisabled,omitempty"` - // Rank - Possible values include: 'None', 'Low', 'Medium', 'High', 'Critical' + // Rank - Possible values include: 'SensitivityLabelRankNone', 'SensitivityLabelRankLow', 'SensitivityLabelRankMedium', 'SensitivityLabelRankHigh', 'SensitivityLabelRankCritical' Rank SensitivityLabelRank `json:"rank,omitempty"` } diff --git a/services/preview/sql/mgmt/v3.0/sql/CHANGELOG.md b/services/preview/sql/mgmt/v3.0/sql/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/sql/mgmt/v3.0/sql/_meta.json b/services/preview/sql/mgmt/v3.0/sql/_meta.json new file mode 100644 index 000000000000..d0ade462727f --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", + "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "tag": "package-composite-v3", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-composite-v3 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/sql/mgmt/v4.0/sql/backuplongtermretentionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/backuplongtermretentionpolicies.go similarity index 100% rename from services/preview/sql/mgmt/v4.0/sql/backuplongtermretentionpolicies.go rename to services/preview/sql/mgmt/v3.0/sql/backuplongtermretentionpolicies.go diff --git a/services/preview/sql/mgmt/v3.0/sql/backupshorttermretentionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/backupshorttermretentionpolicies.go new file mode 100644 index 000000000000..c9bf2b72f18f --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/backupshorttermretentionpolicies.go @@ -0,0 +1,407 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// BackupShortTermRetentionPoliciesClient 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 BackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewBackupShortTermRetentionPoliciesClient creates an instance of the BackupShortTermRetentionPoliciesClient client. +func NewBackupShortTermRetentionPoliciesClient(subscriptionID string) BackupShortTermRetentionPoliciesClient { + return NewBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// BackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupShortTermRetentionPoliciesClient { + return BackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (result BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 BackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client BackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "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.BackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/backupShortTermRetentionPolicies/{policyName}", 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 BackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.bstrplr.Response.Response != nil { + sc = result.bstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.bstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.bstrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.bstrplr.hasNextLink() && result.bstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabasePreparer(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 = "2017-10-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}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result BackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client BackupShortTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults BackupShortTermRetentionPolicyListResult) (result BackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.backupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// Update updates a database's short term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client BackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (result BackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 BackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future BackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/capabilities.go b/services/preview/sql/mgmt/v3.0/sql/capabilities.go new file mode 100644 index 000000000000..c8bc3fe4b21b --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/capabilities.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// CapabilitiesClient 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 CapabilitiesClient struct { + BaseClient +} + +// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. +func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { + return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCapabilitiesClientWithBaseURI creates an instance of the CapabilitiesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the subscription capabilities available for the specified location. +// Parameters: +// locationName - the location name whose capabilities are retrieved. +// include - if specified, restricts the response to only include the selected item. +func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationName string, include CapabilityGroup) (result LocationCapabilities, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByLocationPreparer(ctx, locationName, include) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationName string, include CapabilityGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(include)) > 0 { + queryParameters["include"] = autorest.Encode("query", include) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/client.go b/services/preview/sql/mgmt/v3.0/sql/client.go new file mode 100644 index 000000000000..99340489081a --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/client.go @@ -0,0 +1,42 @@ +// Package sql implements the Azure ARM Sql service API version . +// +// 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. +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Sql + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Sql. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databaseautomatictuning.go b/services/preview/sql/mgmt/v3.0/sql/databaseautomatictuning.go new file mode 100644 index 000000000000..b75b6e41f640 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databaseautomatictuning.go @@ -0,0 +1,195 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "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 using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDatabaseAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAutomaticTuningClient { + return DatabaseAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database's automatic tuning. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAutomaticTuningClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning properties for target database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAutomaticTuningClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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.AsContentType("application/json; charset=utf-8"), + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databaseblobauditingpolicies.go b/services/preview/sql/mgmt/v3.0/sql/databaseblobauditingpolicies.go new file mode 100644 index 000000000000..aa58f533fcd2 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databaseblobauditingpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseBlobAuditingPoliciesClient 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 DatabaseBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewDatabaseBlobAuditingPoliciesClient creates an instance of the DatabaseBlobAuditingPoliciesClient client. +func NewDatabaseBlobAuditingPoliciesClient(subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return NewDatabaseBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseBlobAuditingPoliciesClientWithBaseURI creates an instance of the DatabaseBlobAuditingPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return DatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the database blob auditing policy. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (result DatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "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.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "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, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}", 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 DatabaseBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "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.DatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "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}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}", 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 DatabaseBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists auditing settings of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.dbaplr.Response.Response != nil { + sc = result.dbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dbaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dbaplr.hasNextLink() && result.dbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer(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 = "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}/databases/{databaseName}/auditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseBlobAuditingPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseBlobAuditingPolicyListResult) (result DatabaseBlobAuditingPolicyListResult, err error) { + req, err := lastResults.databaseBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databaseoperations.go b/services/preview/sql/mgmt/v3.0/sql/databaseoperations.go new file mode 100644 index 000000000000..48ced4d98663 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databaseoperations.go @@ -0,0 +1,236 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// DatabaseOperationsClient 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 DatabaseOperationsClient struct { + BaseClient +} + +// NewDatabaseOperationsClient creates an instance of the DatabaseOperationsClient client. +func NewDatabaseOperationsClient(subscriptionID string) DatabaseOperationsClient { + return NewDatabaseOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseOperationsClientWithBaseURI creates an instance of the DatabaseOperationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseOperationsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseOperationsClient { + return DatabaseOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// operationID - the operation identifier. +func (client DatabaseOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, databaseName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client DatabaseOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/databases/{databaseName}/operations/{operationId}/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 DatabaseOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase gets a list of operations performed on the database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseOperationsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dolr.Response.Response != nil { + sc = result.dolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dolr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dolr.hasNextLink() && result.dolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseOperationsClient) ListByDatabasePreparer(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 = "2017-10-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}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseOperationsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseOperationsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseOperationListResult) (result DatabaseOperationListResult, err error) { + req, err := lastResults.databaseOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseOperationsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databases.go b/services/preview/sql/mgmt/v3.0/sql/databases.go new file mode 100644 index 000000000000..7befcba34197 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databases.go @@ -0,0 +1,1407 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabasesClient 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 DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.DatabaseProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseProperties.CurrentSku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseProperties.CurrentSku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (*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 = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.ManagedBy = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) CreateOrUpdateSender(req *http.Request) (future DatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(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 = "2019-06-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}/databases/{databaseName}", 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 DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Export exports a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the database export request parameters. +func (client DatabasesClient) Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExportDatabaseDefinition) (result DatabasesExportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Export") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Export", err.Error()) + } + + req, err := client.ExportPreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", nil, "Failure preparing request") + return + } + + result, err = client.ExportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", result.Response(), "Failure sending request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabasesClient) ExportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExportDatabaseDefinition) (*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 = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ExportSender(req *http.Request) (future DatabasesExportFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ExportResponder(resp *http.Response) (result ImportExportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Failover failovers a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to failover. +// replicaType - the type of replica to be failed over. +func (client DatabasesClient) Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, replicaType ReplicaType) (result DatabasesFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, databaseName, replicaType) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client DatabasesClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, replicaType ReplicaType) (*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 = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(replicaType)) > 0 { + queryParameters["replicaType"] = autorest.Encode("query", replicaType) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) FailoverSender(req *http.Request) (future DatabasesFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client DatabasesClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "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.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) 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 = "2019-06-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}", 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 DatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByElasticPool gets a list of databases in an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client DatabasesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByElasticPoolNextResults + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client DatabasesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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}/elasticPools/{elasticPoolName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByElasticPoolNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByElasticPoolNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByElasticPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} + +// ListByServer gets a list of databases. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) 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 = "2019-06-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", 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 DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + 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 DatabasesClient) listByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "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.DatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// ListInaccessibleByServer gets a list of inaccessible databases in a logical server +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client DatabasesClient) ListInaccessibleByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListInaccessibleByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listInaccessibleByServerNextResults + req, err := client.ListInaccessibleByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListInaccessibleByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListInaccessibleByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListInaccessibleByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListInaccessibleByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListInaccessibleByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListInaccessibleByServerPreparer prepares the ListInaccessibleByServer request. +func (client DatabasesClient) ListInaccessibleByServerPreparer(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 = "2019-06-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}/inaccessibleDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInaccessibleByServerSender sends the ListInaccessibleByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListInaccessibleByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInaccessibleByServerResponder handles the response to the ListInaccessibleByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListInaccessibleByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInaccessibleByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listInaccessibleByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listInaccessibleByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInaccessibleByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listInaccessibleByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInaccessibleByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listInaccessibleByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInaccessibleByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListInaccessibleByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListInaccessibleByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListInaccessibleByServer(ctx, resourceGroupName, serverName) + return +} + +// ListMetricDefinitions returns database metric definitions. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result MetricDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabasesClient) ListMetricDefinitionsPreparer(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 = "2014-04-01" + 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}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns database metrics. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// filter - an OData filter expression that describes a subset of metrics to return. +func (client DatabasesClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabasesClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter 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 = "2014-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "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}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Pause pauses a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be paused. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Pause") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PausePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "Failure preparing request") + return + } + + result, err = client.PauseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", result.Response(), "Failure sending request") + return + } + + return +} + +// PausePreparer prepares the Pause request. +func (client DatabasesClient) PausePreparer(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 = "2019-06-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}/databases/{databaseName}/pause", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PauseSender sends the Pause request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) PauseSender(req *http.Request) (future DatabasesPauseFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// PauseResponder handles the response to the Pause request. The method always +// closes the http.Response Body. +func (client DatabasesClient) PauseResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Rename renames a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to rename. +// parameters - the resource move definition for renaming this database. +func (client DatabasesClient) Rename(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ResourceMoveDefinition) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Rename") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Rename", err.Error()) + } + + req, err := client.RenamePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", nil, "Failure preparing request") + return + } + + resp, err := client.RenameSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", resp, "Failure sending request") + return + } + + result, err = client.RenameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", resp, "Failure responding to request") + return + } + + return +} + +// RenamePreparer prepares the Rename request. +func (client DatabasesClient) RenamePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ResourceMoveDefinition) (*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 = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RenameSender sends the Rename request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) RenameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RenameResponder handles the response to the Rename request. The method always +// closes the http.Response Body. +func (client DatabasesClient) RenameResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be resumed. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Resume") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ResumePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "Failure preparing request") + return + } + + result, err = client.ResumeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", result.Response(), "Failure sending request") + return + } + + return +} + +// ResumePreparer prepares the Resume request. +func (client DatabasesClient) ResumePreparer(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 = "2019-06-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}/databases/{databaseName}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ResumeSender(req *http.Request) (future DatabasesResumeFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ResumeResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client DatabasesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (result DatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (*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 = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", 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 DatabasesClient) UpdateSender(req *http.Request) (future DatabasesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeDataWarehouse upgrades a data warehouse. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to be upgraded. +func (client DatabasesClient) UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesUpgradeDataWarehouseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.UpgradeDataWarehouse") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpgradeDataWarehousePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "UpgradeDataWarehouse", nil, "Failure preparing request") + return + } + + result, err = client.UpgradeDataWarehouseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "UpgradeDataWarehouse", result.Response(), "Failure sending request") + return + } + + return +} + +// UpgradeDataWarehousePreparer prepares the UpgradeDataWarehouse request. +func (client DatabasesClient) UpgradeDataWarehousePreparer(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 = "2019-06-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}/databases/{databaseName}/upgradeDataWarehouse", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpgradeDataWarehouseSender sends the UpgradeDataWarehouse request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) UpgradeDataWarehouseSender(req *http.Request) (future DatabasesUpgradeDataWarehouseFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpgradeDataWarehouseResponder handles the response to the UpgradeDataWarehouse request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpgradeDataWarehouseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databasethreatdetectionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/databasethreatdetectionpolicies.go new file mode 100644 index 000000000000..5034e53cfadb --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databasethreatdetectionpolicies.go @@ -0,0 +1,198 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseThreatDetectionPoliciesClient 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 DatabaseThreatDetectionPoliciesClient struct { + BaseClient +} + +// NewDatabaseThreatDetectionPoliciesClient creates an instance of the DatabaseThreatDetectionPoliciesClient client. +func NewDatabaseThreatDetectionPoliciesClient(subscriptionID string) DatabaseThreatDetectionPoliciesClient { + return NewDatabaseThreatDetectionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseThreatDetectionPoliciesClientWithBaseURI creates an instance of the DatabaseThreatDetectionPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDatabaseThreatDetectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseThreatDetectionPoliciesClient { + return DatabaseThreatDetectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's threat detection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which database Threat Detection policy is defined. +// parameters - the database Threat Detection policy. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (result DatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseThreatDetectionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "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.DatabaseThreatDetectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", 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 DatabaseThreatDetectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's threat detection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which database Threat Detection policy is defined. +func (client DatabaseThreatDetectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseThreatDetectionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "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.DatabaseThreatDetectionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseThreatDetectionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseThreatDetectionPoliciesClient) 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), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/securityAlertPolicies/{securityAlertPolicyName}", 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 DatabaseThreatDetectionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) GetResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databaseusages.go b/services/preview/sql/mgmt/v3.0/sql/databaseusages.go new file mode 100644 index 000000000000..157fddb468b6 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databaseusages.go @@ -0,0 +1,112 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseUsagesClient 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 DatabaseUsagesClient struct { + BaseClient +} + +// NewDatabaseUsagesClient creates an instance of the DatabaseUsagesClient client. +func NewDatabaseUsagesClient(subscriptionID string) DatabaseUsagesClient { + return NewDatabaseUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseUsagesClientWithBaseURI creates an instance of the DatabaseUsagesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseUsagesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseUsagesClient { + return DatabaseUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase returns database usages. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseUsagesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseUsagesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseUsagesClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseUsagesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseUsagesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentrulebaselines.go b/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentrulebaselines.go new file mode 100644 index 000000000000..39a429dfabff --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentrulebaselines.go @@ -0,0 +1,300 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentRuleBaselinesClient 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 DatabaseVulnerabilityAssessmentRuleBaselinesClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentRuleBaselinesClient creates an instance of the +// DatabaseVulnerabilityAssessmentRuleBaselinesClient client. +func NewDatabaseVulnerabilityAssessmentRuleBaselinesClient(subscriptionID string) DatabaseVulnerabilityAssessmentRuleBaselinesClient { + return NewDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentRuleBaselinesClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentRuleBaselinesClient { + return DatabaseVulnerabilityAssessmentRuleBaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +// parameters - the requested rule baseline resource. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentRuleBaselinesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties.BaselineResults", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, ruleID, baselineName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "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.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentRuleBaselinesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + 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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 DatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentRuleBaselinesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "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.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + 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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 DatabaseVulnerabilityAssessmentRuleBaselinesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessments.go b/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessments.go new file mode 100644 index 000000000000..7e8a7e55ce2c --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessments.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentsClient 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 DatabaseVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentsClient creates an instance of the DatabaseVulnerabilityAssessmentsClient client. +func NewDatabaseVulnerabilityAssessmentsClient(subscriptionID string) DatabaseVulnerabilityAssessmentsClient { + return NewDatabaseVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentsClient { + return DatabaseVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the database's vulnerability assessment. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "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.DatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (*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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 DatabaseVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client DatabaseVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabaseVulnerabilityAssessmentsClient) DeletePreparer(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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + 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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 DatabaseVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the database's vulnerability assessment. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client DatabaseVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "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.DatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentsClient) 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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + 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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 DatabaseVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists the vulnerability assessment policies associated with a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment policies are defined. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dvalr.Response.Response != nil { + sc = result.dvalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dvalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dvalr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dvalr.hasNextLink() && result.dvalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabasePreparer(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 = "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}/databases/{databaseName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseVulnerabilityAssessmentsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseVulnerabilityAssessmentListResult) (result DatabaseVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.databaseVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentscans.go b/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentscans.go new file mode 100644 index 000000000000..b9e0362af212 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/databasevulnerabilityassessmentscans.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentScansClient 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 DatabaseVulnerabilityAssessmentScansClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentScansClient creates an instance of the DatabaseVulnerabilityAssessmentScansClient +// client. +func NewDatabaseVulnerabilityAssessmentScansClient(subscriptionID string) DatabaseVulnerabilityAssessmentScansClient { + return NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentScansClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentScansClient { + return DatabaseVulnerabilityAssessmentScansClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export convert an existing scan result to a human readable format. If already exists nothing happens +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the scanned database. +// scanID - the vulnerability assessment scan Id. +func (client DatabaseVulnerabilityAssessmentScansClient) Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.Export") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExportPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure responding to request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a vulnerability assessment scan record of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client DatabaseVulnerabilityAssessmentScansClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result VulnerabilityAssessmentScanRecord, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "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.DatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentScansClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", 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 DatabaseVulnerabilityAssessmentScansClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) GetResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecord, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitiateScan executes a Vulnerability Assessment database scan. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScan(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.InitiateScan") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiateScanPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure preparing request") + return + } + + result, err = client.InitiateScanSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "InitiateScan", result.Response(), "Failure sending request") + return + } + + return +} + +// InitiateScanPreparer prepares the InitiateScan request. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateScanSender sends the InitiateScan request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanSender(req *http.Request) (future DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// InitiateScanResponder handles the response to the InitiateScan request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase lists the vulnerability assessment scans of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.vasrlr.Response.Response != nil { + sc = result.vasrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.vasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.vasrlr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.vasrlr.hasNextLink() && result.vasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabasePreparer(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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecordListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseVulnerabilityAssessmentScansClient) listByDatabaseNextResults(ctx context.Context, lastResults VulnerabilityAssessmentScanRecordListResult) (result VulnerabilityAssessmentScanRecordListResult, err error) { + req, err := lastResults.vulnerabilityAssessmentScanRecordListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/datamaskingpolicies.go b/services/preview/sql/mgmt/v3.0/sql/datamaskingpolicies.go new file mode 100644 index 000000000000..bd6726530f7e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/datamaskingpolicies.go @@ -0,0 +1,199 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DataMaskingPoliciesClient 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 DataMaskingPoliciesClient struct { + BaseClient +} + +// NewDataMaskingPoliciesClient creates an instance of the DataMaskingPoliciesClient client. +func NewDataMaskingPoliciesClient(subscriptionID string) DataMaskingPoliciesClient { + return NewDataMaskingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataMaskingPoliciesClientWithBaseURI creates an instance of the DataMaskingPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataMaskingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingPoliciesClient { + return DataMaskingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking policy +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - parameters for creating or updating a data masking policy. +func (client DataMaskingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DataMaskingPolicy) (result DataMaskingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "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.DataMaskingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataMaskingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DataMaskingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}", 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 DataMaskingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database data masking policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DataMaskingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "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.DataMaskingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataMaskingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/dataMaskingPolicies/{dataMaskingPolicyName}", 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 DataMaskingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) GetResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/datamaskingrules.go b/services/preview/sql/mgmt/v3.0/sql/datamaskingrules.go new file mode 100644 index 000000000000..eae0c8e07f66 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/datamaskingrules.go @@ -0,0 +1,212 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataMaskingRulesClient 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 DataMaskingRulesClient struct { + BaseClient +} + +// NewDataMaskingRulesClient creates an instance of the DataMaskingRulesClient client. +func NewDataMaskingRulesClient(subscriptionID string) DataMaskingRulesClient { + return NewDataMaskingRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataMaskingRulesClientWithBaseURI creates an instance of the DataMaskingRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataMaskingRulesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingRulesClient { + return DataMaskingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// dataMaskingRuleName - the name of the data masking rule. +// parameters - the required parameters for creating or updating a data masking rule. +func (client DataMaskingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (result DataMaskingRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties.SchemaName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DataMaskingRuleProperties.TableName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DataMaskingRuleProperties.ColumnName", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.DataMaskingRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, dataMaskingRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "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.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataMaskingRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "dataMaskingRuleName": autorest.Encode("path", dataMaskingRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", 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 DataMaskingRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database data masking rules. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DataMaskingRulesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingRuleListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingRulesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DataMaskingRulesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DataMaskingRulesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) ListByDatabaseResponder(resp *http.Response) (result DataMaskingRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/elasticpoolactivities.go b/services/preview/sql/mgmt/v3.0/sql/elasticpoolactivities.go new file mode 100644 index 000000000000..441f57b95c41 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/elasticpoolactivities.go @@ -0,0 +1,113 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ElasticPoolActivitiesClient 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 ElasticPoolActivitiesClient struct { + BaseClient +} + +// NewElasticPoolActivitiesClient creates an instance of the ElasticPoolActivitiesClient client. +func NewElasticPoolActivitiesClient(subscriptionID string) ElasticPoolActivitiesClient { + return NewElasticPoolActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolActivitiesClientWithBaseURI creates an instance of the ElasticPoolActivitiesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewElasticPoolActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolActivitiesClient { + return ElasticPoolActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns elastic pool activities. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool for which to get the current activity. +func (client ElasticPoolActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolActivitiesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/elasticPoolActivity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/elasticpooldatabaseactivities.go b/services/preview/sql/mgmt/v3.0/sql/elasticpooldatabaseactivities.go new file mode 100644 index 000000000000..ea65995b62c9 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/elasticpooldatabaseactivities.go @@ -0,0 +1,113 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ElasticPoolDatabaseActivitiesClient 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 ElasticPoolDatabaseActivitiesClient struct { + BaseClient +} + +// NewElasticPoolDatabaseActivitiesClient creates an instance of the ElasticPoolDatabaseActivitiesClient client. +func NewElasticPoolDatabaseActivitiesClient(subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return NewElasticPoolDatabaseActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolDatabaseActivitiesClientWithBaseURI creates an instance of the ElasticPoolDatabaseActivitiesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewElasticPoolDatabaseActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return ElasticPoolDatabaseActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns activity on databases inside of an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolDatabaseActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolDatabaseActivitiesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolDatabaseActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/elasticpooloperations.go b/services/preview/sql/mgmt/v3.0/sql/elasticpooloperations.go new file mode 100644 index 000000000000..d8bd4555a2cc --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/elasticpooloperations.go @@ -0,0 +1,234 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// ElasticPoolOperationsClient 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 ElasticPoolOperationsClient struct { + BaseClient +} + +// NewElasticPoolOperationsClient creates an instance of the ElasticPoolOperationsClient client. +func NewElasticPoolOperationsClient(subscriptionID string) ElasticPoolOperationsClient { + return NewElasticPoolOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolOperationsClientWithBaseURI creates an instance of the ElasticPoolOperationsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewElasticPoolOperationsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolOperationsClient { + return ElasticPoolOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// operationID - the operation identifier. +func (client ElasticPoolOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, elasticPoolName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client ElasticPoolOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}/operations/{operationId}/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 ElasticPoolOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByElasticPool gets a list of operations performed on the elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ElasticPoolOperationsClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.ListByElasticPool") + defer func() { + sc := -1 + if result.epolr.Response.Response != nil { + sc = result.epolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByElasticPoolNextResults + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.epolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result.epolr, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + if result.epolr.hasNextLink() && result.epolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolOperationsClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolOperationsClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByElasticPoolNextResults retrieves the next set of results, if any. +func (client ElasticPoolOperationsClient) listByElasticPoolNextResults(ctx context.Context, lastResults ElasticPoolOperationListResult) (result ElasticPoolOperationListResult, err error) { + req, err := lastResults.elasticPoolOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByElasticPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client ElasticPoolOperationsClient) ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/elasticpools.go b/services/preview/sql/mgmt/v3.0/sql/elasticpools.go new file mode 100644 index 000000000000..0ba04c8fe619 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/elasticpools.go @@ -0,0 +1,736 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ElasticPoolsClient 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 ElasticPoolsClient struct { + BaseClient +} + +// NewElasticPoolsClient creates an instance of the ElasticPoolsClient client. +func NewElasticPoolsClient(subscriptionID string) ElasticPoolsClient { + return NewElasticPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolsClientWithBaseURI creates an instance of the ElasticPoolsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +// parameters - the elastic pool parameters. +func (client ElasticPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (result ElasticPoolsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ElasticPoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ElasticPoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) CreateOrUpdateSender(req *http.Request) (future ElasticPoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ElasticPoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) DeleteSender(req *http.Request) (future ElasticPoolsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover failovers an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool to failover. +func (client ElasticPoolsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ElasticPoolsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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}/elasticPools/{elasticPoolName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) FailoverSender(req *http.Request) (future ElasticPoolsFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "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.ElasticPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ElasticPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all elastic pools in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// skip - the number of elements in the collection to skip. +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.eplr.Response.Response != nil { + sc = result.eplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.eplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.eplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.eplr.hasNextLink() && result.eplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ElasticPoolsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (*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-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if skip != nil { + 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}/elasticPools", 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 ElasticPoolsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + 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 ElasticPoolsClient) listByServerNextResults(ctx context.Context, lastResults ElasticPoolListResult) (result ElasticPoolListResult, err error) { + req, err := lastResults.elasticPoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "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.ElasticPoolsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ElasticPoolsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName, skip) + return +} + +// ListMetricDefinitions returns elastic pool metric definitions. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result MetricDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client ElasticPoolsClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/elasticPools/{elasticPoolName}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns elastic pool metrics. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +// filter - an OData filter expression that describes a subset of metrics to return. +func (client ElasticPoolsClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, elasticPoolName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client ElasticPoolsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// elasticPoolName - the name of the elastic pool. +// parameters - the elastic pool update parameters. +func (client ElasticPoolsClient) Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (result ElasticPoolsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ElasticPoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", 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 ElasticPoolsClient) UpdateSender(req *http.Request) (future ElasticPoolsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/encryptionprotectors.go b/services/preview/sql/mgmt/v3.0/sql/encryptionprotectors.go new file mode 100644 index 000000000000..14c45a85d0a3 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/encryptionprotectors.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// EncryptionProtectorsClient 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 EncryptionProtectorsClient struct { + BaseClient +} + +// NewEncryptionProtectorsClient creates an instance of the EncryptionProtectorsClient client. +func NewEncryptionProtectorsClient(subscriptionID string) EncryptionProtectorsClient { + return NewEncryptionProtectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEncryptionProtectorsClientWithBaseURI creates an instance of the EncryptionProtectorsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) EncryptionProtectorsClient { + return EncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested encryption protector resource state. +func (client EncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (result EncryptionProtectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client EncryptionProtectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "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, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}", 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 EncryptionProtectorsClient) CreateOrUpdateSender(req *http.Request) (future EncryptionProtectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) CreateOrUpdateResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server encryption protector. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client EncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "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.EncryptionProtectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EncryptionProtectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "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}/encryptionProtector/{encryptionProtectorName}", 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 EncryptionProtectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) GetResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server encryption protectors +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client EncryptionProtectorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.ListByServer") + defer func() { + sc := -1 + if result.eplr.Response.Response != nil { + sc = result.eplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.eplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.eplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.eplr.hasNextLink() && result.eplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client EncryptionProtectorsClient) 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 = "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}/encryptionProtector", 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 EncryptionProtectorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) ListByServerResponder(resp *http.Response) (result EncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + 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 EncryptionProtectorsClient) listByServerNextResults(ctx context.Context, lastResults EncryptionProtectorListResult) (result EncryptionProtectorListResult, err error) { + req, err := lastResults.encryptionProtectorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "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.EncryptionProtectorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client EncryptionProtectorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Revalidate revalidates an existing encryption protector. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client EncryptionProtectorsClient) Revalidate(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorsRevalidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.Revalidate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RevalidatePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Revalidate", nil, "Failure preparing request") + return + } + + result, err = client.RevalidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Revalidate", result.Response(), "Failure sending request") + return + } + + return +} + +// RevalidatePreparer prepares the Revalidate request. +func (client EncryptionProtectorsClient) RevalidatePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "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.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevalidateSender sends the Revalidate request. The method will close the +// http.Response Body if it receives an error. +func (client EncryptionProtectorsClient) RevalidateSender(req *http.Request) (future EncryptionProtectorsRevalidateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RevalidateResponder handles the response to the Revalidate request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) RevalidateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/enums.go b/services/preview/sql/mgmt/v3.0/sql/enums.go new file mode 100644 index 000000000000..ad274f8a6696 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/enums.go @@ -0,0 +1,1987 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AggregationFunctionType enumerates the values for aggregation function type. +type AggregationFunctionType string + +const ( + // Avg ... + Avg AggregationFunctionType = "avg" + // Max ... + Max AggregationFunctionType = "max" + // Min ... + Min AggregationFunctionType = "min" + // Stdev ... + Stdev AggregationFunctionType = "stdev" + // Sum ... + Sum AggregationFunctionType = "sum" +) + +// PossibleAggregationFunctionTypeValues returns an array of possible values for the AggregationFunctionType const type. +func PossibleAggregationFunctionTypeValues() []AggregationFunctionType { + return []AggregationFunctionType{Avg, Max, Min, Stdev, Sum} +} + +// 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" +) + +// PossibleAutomaticTuningDisabledReasonValues returns an array of possible values for the AutomaticTuningDisabledReason const type. +func PossibleAutomaticTuningDisabledReasonValues() []AutomaticTuningDisabledReason { + return []AutomaticTuningDisabledReason{AutoConfigured, Default, Disabled, InheritedFromServer, NotSupported, QueryStoreOff, 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" +) + +// PossibleAutomaticTuningModeValues returns an array of possible values for the AutomaticTuningMode const type. +func PossibleAutomaticTuningModeValues() []AutomaticTuningMode { + return []AutomaticTuningMode{Auto, Custom, Inherit, Unspecified} +} + +// AutomaticTuningOptionModeActual enumerates the values for automatic tuning option mode actual. +type AutomaticTuningOptionModeActual string + +const ( + // Off ... + Off AutomaticTuningOptionModeActual = "Off" + // On ... + On AutomaticTuningOptionModeActual = "On" +) + +// PossibleAutomaticTuningOptionModeActualValues returns an array of possible values for the AutomaticTuningOptionModeActual const type. +func PossibleAutomaticTuningOptionModeActualValues() []AutomaticTuningOptionModeActual { + return []AutomaticTuningOptionModeActual{Off, 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" +) + +// PossibleAutomaticTuningOptionModeDesiredValues returns an array of possible values for the AutomaticTuningOptionModeDesired const type. +func PossibleAutomaticTuningOptionModeDesiredValues() []AutomaticTuningOptionModeDesired { + return []AutomaticTuningOptionModeDesired{AutomaticTuningOptionModeDesiredDefault, AutomaticTuningOptionModeDesiredOff, AutomaticTuningOptionModeDesiredOn} +} + +// 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" +) + +// PossibleAutomaticTuningServerModeValues returns an array of possible values for the AutomaticTuningServerMode const type. +func PossibleAutomaticTuningServerModeValues() []AutomaticTuningServerMode { + return []AutomaticTuningServerMode{AutomaticTuningServerModeAuto, AutomaticTuningServerModeCustom, AutomaticTuningServerModeUnspecified} +} + +// 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" +) + +// PossibleAutomaticTuningServerReasonValues returns an array of possible values for the AutomaticTuningServerReason const type. +func PossibleAutomaticTuningServerReasonValues() []AutomaticTuningServerReason { + return []AutomaticTuningServerReason{AutomaticTuningServerReasonAutoConfigured, AutomaticTuningServerReasonDefault, AutomaticTuningServerReasonDisabled} +} + +// BlobAuditingPolicyState enumerates the values for blob auditing policy state. +type BlobAuditingPolicyState string + +const ( + // BlobAuditingPolicyStateDisabled ... + BlobAuditingPolicyStateDisabled BlobAuditingPolicyState = "Disabled" + // BlobAuditingPolicyStateEnabled ... + BlobAuditingPolicyStateEnabled BlobAuditingPolicyState = "Enabled" +) + +// PossibleBlobAuditingPolicyStateValues returns an array of possible values for the BlobAuditingPolicyState const type. +func PossibleBlobAuditingPolicyStateValues() []BlobAuditingPolicyState { + return []BlobAuditingPolicyState{BlobAuditingPolicyStateDisabled, BlobAuditingPolicyStateEnabled} +} + +// CapabilityGroup enumerates the values for capability group. +type CapabilityGroup string + +const ( + // SupportedEditions ... + SupportedEditions CapabilityGroup = "supportedEditions" + // SupportedElasticPoolEditions ... + SupportedElasticPoolEditions CapabilityGroup = "supportedElasticPoolEditions" + // SupportedInstancePoolEditions ... + SupportedInstancePoolEditions CapabilityGroup = "supportedInstancePoolEditions" + // SupportedManagedInstanceEditions ... + SupportedManagedInstanceEditions CapabilityGroup = "supportedManagedInstanceEditions" + // SupportedManagedInstanceVersions ... + SupportedManagedInstanceVersions CapabilityGroup = "supportedManagedInstanceVersions" +) + +// PossibleCapabilityGroupValues returns an array of possible values for the CapabilityGroup const type. +func PossibleCapabilityGroupValues() []CapabilityGroup { + return []CapabilityGroup{SupportedEditions, SupportedElasticPoolEditions, SupportedInstancePoolEditions, SupportedManagedInstanceEditions, SupportedManagedInstanceVersions} +} + +// CapabilityStatus enumerates the values for capability status. +type CapabilityStatus string + +const ( + // CapabilityStatusAvailable ... + CapabilityStatusAvailable CapabilityStatus = "Available" + // CapabilityStatusDefault ... + CapabilityStatusDefault CapabilityStatus = "Default" + // CapabilityStatusDisabled ... + CapabilityStatusDisabled CapabilityStatus = "Disabled" + // CapabilityStatusVisible ... + CapabilityStatusVisible CapabilityStatus = "Visible" +) + +// PossibleCapabilityStatusValues returns an array of possible values for the CapabilityStatus const type. +func PossibleCapabilityStatusValues() []CapabilityStatus { + return []CapabilityStatus{CapabilityStatusAvailable, CapabilityStatusDefault, CapabilityStatusDisabled, CapabilityStatusVisible} +} + +// CatalogCollationType enumerates the values for catalog collation type. +type CatalogCollationType string + +const ( + // DATABASEDEFAULT ... + DATABASEDEFAULT CatalogCollationType = "DATABASE_DEFAULT" + // SQLLatin1GeneralCP1CIAS ... + SQLLatin1GeneralCP1CIAS CatalogCollationType = "SQL_Latin1_General_CP1_CI_AS" +) + +// PossibleCatalogCollationTypeValues returns an array of possible values for the CatalogCollationType const type. +func PossibleCatalogCollationTypeValues() []CatalogCollationType { + return []CatalogCollationType{DATABASEDEFAULT, SQLLatin1GeneralCP1CIAS} +} + +// CheckNameAvailabilityReason enumerates the values for check name availability reason. +type CheckNameAvailabilityReason string + +const ( + // AlreadyExists ... + AlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + // Invalid ... + Invalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns an array of possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{AlreadyExists, Invalid} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // CreateModeCopy ... + CreateModeCopy CreateMode = "Copy" + // CreateModeDefault ... + CreateModeDefault CreateMode = "Default" + // CreateModeOnlineSecondary ... + CreateModeOnlineSecondary CreateMode = "OnlineSecondary" + // CreateModePointInTimeRestore ... + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeRecovery ... + CreateModeRecovery CreateMode = "Recovery" + // CreateModeRestore ... + CreateModeRestore CreateMode = "Restore" + // CreateModeRestoreExternalBackup ... + CreateModeRestoreExternalBackup CreateMode = "RestoreExternalBackup" + // CreateModeRestoreExternalBackupSecondary ... + CreateModeRestoreExternalBackupSecondary CreateMode = "RestoreExternalBackupSecondary" + // CreateModeRestoreLongTermRetentionBackup ... + CreateModeRestoreLongTermRetentionBackup CreateMode = "RestoreLongTermRetentionBackup" + // CreateModeSecondary ... + CreateModeSecondary CreateMode = "Secondary" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeCopy, CreateModeDefault, CreateModeOnlineSecondary, CreateModePointInTimeRestore, CreateModeRecovery, CreateModeRestore, CreateModeRestoreExternalBackup, CreateModeRestoreExternalBackupSecondary, CreateModeRestoreLongTermRetentionBackup, CreateModeSecondary} +} + +// DatabaseLicenseType enumerates the values for database license type. +type DatabaseLicenseType string + +const ( + // BasePrice ... + BasePrice DatabaseLicenseType = "BasePrice" + // LicenseIncluded ... + LicenseIncluded DatabaseLicenseType = "LicenseIncluded" +) + +// PossibleDatabaseLicenseTypeValues returns an array of possible values for the DatabaseLicenseType const type. +func PossibleDatabaseLicenseTypeValues() []DatabaseLicenseType { + return []DatabaseLicenseType{BasePrice, LicenseIncluded} +} + +// DatabaseReadScale enumerates the values for database read scale. +type DatabaseReadScale string + +const ( + // DatabaseReadScaleDisabled ... + DatabaseReadScaleDisabled DatabaseReadScale = "Disabled" + // DatabaseReadScaleEnabled ... + DatabaseReadScaleEnabled DatabaseReadScale = "Enabled" +) + +// PossibleDatabaseReadScaleValues returns an array of possible values for the DatabaseReadScale const type. +func PossibleDatabaseReadScaleValues() []DatabaseReadScale { + return []DatabaseReadScale{DatabaseReadScaleDisabled, DatabaseReadScaleEnabled} +} + +// DatabaseState1 enumerates the values for database state 1. +type DatabaseState1 string + +const ( + // All ... + All DatabaseState1 = "All" + // Deleted ... + Deleted DatabaseState1 = "Deleted" + // Live ... + Live DatabaseState1 = "Live" +) + +// PossibleDatabaseState1Values returns an array of possible values for the DatabaseState1 const type. +func PossibleDatabaseState1Values() []DatabaseState1 { + return []DatabaseState1{All, Deleted, Live} +} + +// DatabaseState2 enumerates the values for database state 2. +type DatabaseState2 string + +const ( + // DatabaseState2All ... + DatabaseState2All DatabaseState2 = "All" + // DatabaseState2Deleted ... + DatabaseState2Deleted DatabaseState2 = "Deleted" + // DatabaseState2Live ... + DatabaseState2Live DatabaseState2 = "Live" +) + +// PossibleDatabaseState2Values returns an array of possible values for the DatabaseState2 const type. +func PossibleDatabaseState2Values() []DatabaseState2 { + return []DatabaseState2{DatabaseState2All, DatabaseState2Deleted, DatabaseState2Live} +} + +// DatabaseState3 enumerates the values for database state 3. +type DatabaseState3 string + +const ( + // DatabaseState3All ... + DatabaseState3All DatabaseState3 = "All" + // DatabaseState3Deleted ... + DatabaseState3Deleted DatabaseState3 = "Deleted" + // DatabaseState3Live ... + DatabaseState3Live DatabaseState3 = "Live" +) + +// PossibleDatabaseState3Values returns an array of possible values for the DatabaseState3 const type. +func PossibleDatabaseState3Values() []DatabaseState3 { + return []DatabaseState3{DatabaseState3All, DatabaseState3Deleted, DatabaseState3Live} +} + +// DatabaseState4 enumerates the values for database state 4. +type DatabaseState4 string + +const ( + // DatabaseState4All ... + DatabaseState4All DatabaseState4 = "All" + // DatabaseState4Deleted ... + DatabaseState4Deleted DatabaseState4 = "Deleted" + // DatabaseState4Live ... + DatabaseState4Live DatabaseState4 = "Live" +) + +// PossibleDatabaseState4Values returns an array of possible values for the DatabaseState4 const type. +func PossibleDatabaseState4Values() []DatabaseState4 { + return []DatabaseState4{DatabaseState4All, DatabaseState4Deleted, DatabaseState4Live} +} + +// DatabaseState5 enumerates the values for database state 5. +type DatabaseState5 string + +const ( + // DatabaseState5All ... + DatabaseState5All DatabaseState5 = "All" + // DatabaseState5Deleted ... + DatabaseState5Deleted DatabaseState5 = "Deleted" + // DatabaseState5Live ... + DatabaseState5Live DatabaseState5 = "Live" +) + +// PossibleDatabaseState5Values returns an array of possible values for the DatabaseState5 const type. +func PossibleDatabaseState5Values() []DatabaseState5 { + return []DatabaseState5{DatabaseState5All, DatabaseState5Deleted, DatabaseState5Live} +} + +// DatabaseState6 enumerates the values for database state 6. +type DatabaseState6 string + +const ( + // DatabaseState6All ... + DatabaseState6All DatabaseState6 = "All" + // DatabaseState6Deleted ... + DatabaseState6Deleted DatabaseState6 = "Deleted" + // DatabaseState6Live ... + DatabaseState6Live DatabaseState6 = "Live" +) + +// PossibleDatabaseState6Values returns an array of possible values for the DatabaseState6 const type. +func PossibleDatabaseState6Values() []DatabaseState6 { + return []DatabaseState6{DatabaseState6All, DatabaseState6Deleted, DatabaseState6Live} +} + +// DatabaseStatus enumerates the values for database status. +type DatabaseStatus string + +const ( + // DatabaseStatusAutoClosed ... + DatabaseStatusAutoClosed DatabaseStatus = "AutoClosed" + // DatabaseStatusCopying ... + DatabaseStatusCopying DatabaseStatus = "Copying" + // DatabaseStatusCreating ... + DatabaseStatusCreating DatabaseStatus = "Creating" + // DatabaseStatusDisabled ... + DatabaseStatusDisabled DatabaseStatus = "Disabled" + // DatabaseStatusEmergencyMode ... + DatabaseStatusEmergencyMode DatabaseStatus = "EmergencyMode" + // DatabaseStatusInaccessible ... + DatabaseStatusInaccessible DatabaseStatus = "Inaccessible" + // DatabaseStatusOffline ... + DatabaseStatusOffline DatabaseStatus = "Offline" + // DatabaseStatusOfflineChangingDwPerformanceTiers ... + DatabaseStatusOfflineChangingDwPerformanceTiers DatabaseStatus = "OfflineChangingDwPerformanceTiers" + // DatabaseStatusOfflineSecondary ... + DatabaseStatusOfflineSecondary DatabaseStatus = "OfflineSecondary" + // DatabaseStatusOnline ... + DatabaseStatusOnline DatabaseStatus = "Online" + // DatabaseStatusOnlineChangingDwPerformanceTiers ... + DatabaseStatusOnlineChangingDwPerformanceTiers DatabaseStatus = "OnlineChangingDwPerformanceTiers" + // DatabaseStatusPaused ... + DatabaseStatusPaused DatabaseStatus = "Paused" + // DatabaseStatusPausing ... + DatabaseStatusPausing DatabaseStatus = "Pausing" + // DatabaseStatusRecovering ... + DatabaseStatusRecovering DatabaseStatus = "Recovering" + // DatabaseStatusRecoveryPending ... + DatabaseStatusRecoveryPending DatabaseStatus = "RecoveryPending" + // DatabaseStatusRestoring ... + DatabaseStatusRestoring DatabaseStatus = "Restoring" + // DatabaseStatusResuming ... + DatabaseStatusResuming DatabaseStatus = "Resuming" + // DatabaseStatusScaling ... + DatabaseStatusScaling DatabaseStatus = "Scaling" + // DatabaseStatusShutdown ... + DatabaseStatusShutdown DatabaseStatus = "Shutdown" + // DatabaseStatusStandby ... + DatabaseStatusStandby DatabaseStatus = "Standby" + // DatabaseStatusSuspect ... + DatabaseStatusSuspect DatabaseStatus = "Suspect" +) + +// PossibleDatabaseStatusValues returns an array of possible values for the DatabaseStatus const type. +func PossibleDatabaseStatusValues() []DatabaseStatus { + return []DatabaseStatus{DatabaseStatusAutoClosed, DatabaseStatusCopying, DatabaseStatusCreating, DatabaseStatusDisabled, DatabaseStatusEmergencyMode, DatabaseStatusInaccessible, DatabaseStatusOffline, DatabaseStatusOfflineChangingDwPerformanceTiers, DatabaseStatusOfflineSecondary, DatabaseStatusOnline, DatabaseStatusOnlineChangingDwPerformanceTiers, DatabaseStatusPaused, DatabaseStatusPausing, DatabaseStatusRecovering, DatabaseStatusRecoveryPending, DatabaseStatusRestoring, DatabaseStatusResuming, DatabaseStatusScaling, DatabaseStatusShutdown, DatabaseStatusStandby, DatabaseStatusSuspect} +} + +// DataMaskingFunction enumerates the values for data masking function. +type DataMaskingFunction string + +const ( + // DataMaskingFunctionCCN ... + DataMaskingFunctionCCN DataMaskingFunction = "CCN" + // DataMaskingFunctionDefault ... + DataMaskingFunctionDefault DataMaskingFunction = "Default" + // DataMaskingFunctionEmail ... + DataMaskingFunctionEmail DataMaskingFunction = "Email" + // DataMaskingFunctionNumber ... + DataMaskingFunctionNumber DataMaskingFunction = "Number" + // DataMaskingFunctionSSN ... + DataMaskingFunctionSSN DataMaskingFunction = "SSN" + // DataMaskingFunctionText ... + DataMaskingFunctionText DataMaskingFunction = "Text" +) + +// PossibleDataMaskingFunctionValues returns an array of possible values for the DataMaskingFunction const type. +func PossibleDataMaskingFunctionValues() []DataMaskingFunction { + return []DataMaskingFunction{DataMaskingFunctionCCN, DataMaskingFunctionDefault, DataMaskingFunctionEmail, DataMaskingFunctionNumber, DataMaskingFunctionSSN, DataMaskingFunctionText} +} + +// DataMaskingRuleState enumerates the values for data masking rule state. +type DataMaskingRuleState string + +const ( + // DataMaskingRuleStateDisabled ... + DataMaskingRuleStateDisabled DataMaskingRuleState = "Disabled" + // DataMaskingRuleStateEnabled ... + DataMaskingRuleStateEnabled DataMaskingRuleState = "Enabled" +) + +// PossibleDataMaskingRuleStateValues returns an array of possible values for the DataMaskingRuleState const type. +func PossibleDataMaskingRuleStateValues() []DataMaskingRuleState { + return []DataMaskingRuleState{DataMaskingRuleStateDisabled, DataMaskingRuleStateEnabled} +} + +// DataMaskingState enumerates the values for data masking state. +type DataMaskingState string + +const ( + // DataMaskingStateDisabled ... + DataMaskingStateDisabled DataMaskingState = "Disabled" + // DataMaskingStateEnabled ... + DataMaskingStateEnabled DataMaskingState = "Enabled" +) + +// PossibleDataMaskingStateValues returns an array of possible values for the DataMaskingState const type. +func PossibleDataMaskingStateValues() []DataMaskingState { + return []DataMaskingState{DataMaskingStateDisabled, DataMaskingStateEnabled} +} + +// ElasticPoolEdition enumerates the values for elastic pool edition. +type ElasticPoolEdition string + +const ( + // Basic ... + Basic ElasticPoolEdition = "Basic" + // BusinessCritical ... + BusinessCritical ElasticPoolEdition = "BusinessCritical" + // GeneralPurpose ... + GeneralPurpose ElasticPoolEdition = "GeneralPurpose" + // Premium ... + Premium ElasticPoolEdition = "Premium" + // Standard ... + Standard ElasticPoolEdition = "Standard" +) + +// PossibleElasticPoolEditionValues returns an array of possible values for the ElasticPoolEdition const type. +func PossibleElasticPoolEditionValues() []ElasticPoolEdition { + return []ElasticPoolEdition{Basic, BusinessCritical, GeneralPurpose, Premium, Standard} +} + +// ElasticPoolLicenseType enumerates the values for elastic pool license type. +type ElasticPoolLicenseType string + +const ( + // ElasticPoolLicenseTypeBasePrice ... + ElasticPoolLicenseTypeBasePrice ElasticPoolLicenseType = "BasePrice" + // ElasticPoolLicenseTypeLicenseIncluded ... + ElasticPoolLicenseTypeLicenseIncluded ElasticPoolLicenseType = "LicenseIncluded" +) + +// PossibleElasticPoolLicenseTypeValues returns an array of possible values for the ElasticPoolLicenseType const type. +func PossibleElasticPoolLicenseTypeValues() []ElasticPoolLicenseType { + return []ElasticPoolLicenseType{ElasticPoolLicenseTypeBasePrice, ElasticPoolLicenseTypeLicenseIncluded} +} + +// ElasticPoolState enumerates the values for elastic pool state. +type ElasticPoolState string + +const ( + // ElasticPoolStateCreating ... + ElasticPoolStateCreating ElasticPoolState = "Creating" + // ElasticPoolStateDisabled ... + ElasticPoolStateDisabled ElasticPoolState = "Disabled" + // ElasticPoolStateReady ... + ElasticPoolStateReady ElasticPoolState = "Ready" +) + +// PossibleElasticPoolStateValues returns an array of possible values for the ElasticPoolState const type. +func PossibleElasticPoolStateValues() []ElasticPoolState { + return []ElasticPoolState{ElasticPoolStateCreating, ElasticPoolStateDisabled, ElasticPoolStateReady} +} + +// FailoverGroupReplicationRole enumerates the values for failover group replication role. +type FailoverGroupReplicationRole string + +const ( + // Primary ... + Primary FailoverGroupReplicationRole = "Primary" + // Secondary ... + Secondary FailoverGroupReplicationRole = "Secondary" +) + +// PossibleFailoverGroupReplicationRoleValues returns an array of possible values for the FailoverGroupReplicationRole const type. +func PossibleFailoverGroupReplicationRoleValues() []FailoverGroupReplicationRole { + return []FailoverGroupReplicationRole{Primary, Secondary} +} + +// GeoBackupPolicyState enumerates the values for geo backup policy state. +type GeoBackupPolicyState string + +const ( + // GeoBackupPolicyStateDisabled ... + GeoBackupPolicyStateDisabled GeoBackupPolicyState = "Disabled" + // GeoBackupPolicyStateEnabled ... + GeoBackupPolicyStateEnabled GeoBackupPolicyState = "Enabled" +) + +// PossibleGeoBackupPolicyStateValues returns an array of possible values for the GeoBackupPolicyState const type. +func PossibleGeoBackupPolicyStateValues() []GeoBackupPolicyState { + return []GeoBackupPolicyState{GeoBackupPolicyStateDisabled, GeoBackupPolicyStateEnabled} +} + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // None ... + None IdentityType = "None" + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" + // SystemAssignedUserAssigned ... + SystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" + // UserAssigned ... + UserAssigned IdentityType = "UserAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{None, SystemAssigned, SystemAssignedUserAssigned, UserAssigned} +} + +// InstanceFailoverGroupReplicationRole enumerates the values for instance failover group replication role. +type InstanceFailoverGroupReplicationRole string + +const ( + // InstanceFailoverGroupReplicationRolePrimary ... + InstanceFailoverGroupReplicationRolePrimary InstanceFailoverGroupReplicationRole = "Primary" + // InstanceFailoverGroupReplicationRoleSecondary ... + InstanceFailoverGroupReplicationRoleSecondary InstanceFailoverGroupReplicationRole = "Secondary" +) + +// PossibleInstanceFailoverGroupReplicationRoleValues returns an array of possible values for the InstanceFailoverGroupReplicationRole const type. +func PossibleInstanceFailoverGroupReplicationRoleValues() []InstanceFailoverGroupReplicationRole { + return []InstanceFailoverGroupReplicationRole{InstanceFailoverGroupReplicationRolePrimary, InstanceFailoverGroupReplicationRoleSecondary} +} + +// InstancePoolLicenseType enumerates the values for instance pool license type. +type InstancePoolLicenseType string + +const ( + // InstancePoolLicenseTypeBasePrice ... + InstancePoolLicenseTypeBasePrice InstancePoolLicenseType = "BasePrice" + // InstancePoolLicenseTypeLicenseIncluded ... + InstancePoolLicenseTypeLicenseIncluded InstancePoolLicenseType = "LicenseIncluded" +) + +// PossibleInstancePoolLicenseTypeValues returns an array of possible values for the InstancePoolLicenseType const type. +func PossibleInstancePoolLicenseTypeValues() []InstancePoolLicenseType { + return []InstancePoolLicenseType{InstancePoolLicenseTypeBasePrice, InstancePoolLicenseTypeLicenseIncluded} +} + +// JobAgentState enumerates the values for job agent state. +type JobAgentState string + +const ( + // JobAgentStateCreating ... + JobAgentStateCreating JobAgentState = "Creating" + // JobAgentStateDeleting ... + JobAgentStateDeleting JobAgentState = "Deleting" + // JobAgentStateDisabled ... + JobAgentStateDisabled JobAgentState = "Disabled" + // JobAgentStateReady ... + JobAgentStateReady JobAgentState = "Ready" + // JobAgentStateUpdating ... + JobAgentStateUpdating JobAgentState = "Updating" +) + +// PossibleJobAgentStateValues returns an array of possible values for the JobAgentState const type. +func PossibleJobAgentStateValues() []JobAgentState { + return []JobAgentState{JobAgentStateCreating, JobAgentStateDeleting, JobAgentStateDisabled, JobAgentStateReady, JobAgentStateUpdating} +} + +// JobExecutionLifecycle enumerates the values for job execution lifecycle. +type JobExecutionLifecycle string + +const ( + // Canceled ... + Canceled JobExecutionLifecycle = "Canceled" + // Created ... + Created JobExecutionLifecycle = "Created" + // Failed ... + Failed JobExecutionLifecycle = "Failed" + // InProgress ... + InProgress JobExecutionLifecycle = "InProgress" + // Skipped ... + Skipped JobExecutionLifecycle = "Skipped" + // Succeeded ... + Succeeded JobExecutionLifecycle = "Succeeded" + // SucceededWithSkipped ... + SucceededWithSkipped JobExecutionLifecycle = "SucceededWithSkipped" + // TimedOut ... + TimedOut JobExecutionLifecycle = "TimedOut" + // WaitingForChildJobExecutions ... + WaitingForChildJobExecutions JobExecutionLifecycle = "WaitingForChildJobExecutions" + // WaitingForRetry ... + WaitingForRetry JobExecutionLifecycle = "WaitingForRetry" +) + +// PossibleJobExecutionLifecycleValues returns an array of possible values for the JobExecutionLifecycle const type. +func PossibleJobExecutionLifecycleValues() []JobExecutionLifecycle { + return []JobExecutionLifecycle{Canceled, Created, Failed, InProgress, Skipped, Succeeded, SucceededWithSkipped, TimedOut, WaitingForChildJobExecutions, WaitingForRetry} +} + +// JobScheduleType enumerates the values for job schedule type. +type JobScheduleType string + +const ( + // Once ... + Once JobScheduleType = "Once" + // Recurring ... + Recurring JobScheduleType = "Recurring" +) + +// PossibleJobScheduleTypeValues returns an array of possible values for the JobScheduleType const type. +func PossibleJobScheduleTypeValues() []JobScheduleType { + return []JobScheduleType{Once, Recurring} +} + +// JobStepActionSource enumerates the values for job step action source. +type JobStepActionSource string + +const ( + // Inline ... + Inline JobStepActionSource = "Inline" +) + +// PossibleJobStepActionSourceValues returns an array of possible values for the JobStepActionSource const type. +func PossibleJobStepActionSourceValues() []JobStepActionSource { + return []JobStepActionSource{Inline} +} + +// JobStepActionType enumerates the values for job step action type. +type JobStepActionType string + +const ( + // TSQL ... + TSQL JobStepActionType = "TSql" +) + +// PossibleJobStepActionTypeValues returns an array of possible values for the JobStepActionType const type. +func PossibleJobStepActionTypeValues() []JobStepActionType { + return []JobStepActionType{TSQL} +} + +// JobStepOutputType enumerates the values for job step output type. +type JobStepOutputType string + +const ( + // SQLDatabase ... + SQLDatabase JobStepOutputType = "SqlDatabase" +) + +// PossibleJobStepOutputTypeValues returns an array of possible values for the JobStepOutputType const type. +func PossibleJobStepOutputTypeValues() []JobStepOutputType { + return []JobStepOutputType{SQLDatabase} +} + +// JobTargetGroupMembershipType enumerates the values for job target group membership type. +type JobTargetGroupMembershipType string + +const ( + // Exclude ... + Exclude JobTargetGroupMembershipType = "Exclude" + // Include ... + Include JobTargetGroupMembershipType = "Include" +) + +// PossibleJobTargetGroupMembershipTypeValues returns an array of possible values for the JobTargetGroupMembershipType const type. +func PossibleJobTargetGroupMembershipTypeValues() []JobTargetGroupMembershipType { + return []JobTargetGroupMembershipType{Exclude, 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" +) + +// PossibleJobTargetTypeValues returns an array of possible values for the JobTargetType const type. +func PossibleJobTargetTypeValues() []JobTargetType { + return []JobTargetType{JobTargetTypeSQLDatabase, JobTargetTypeSQLElasticPool, JobTargetTypeSQLServer, JobTargetTypeSQLShardMap, JobTargetTypeTargetGroup} +} + +// LogSizeUnit enumerates the values for log size unit. +type LogSizeUnit string + +const ( + // Gigabytes ... + Gigabytes LogSizeUnit = "Gigabytes" + // Megabytes ... + Megabytes LogSizeUnit = "Megabytes" + // Percent ... + Percent LogSizeUnit = "Percent" + // Petabytes ... + Petabytes LogSizeUnit = "Petabytes" + // Terabytes ... + Terabytes LogSizeUnit = "Terabytes" +) + +// PossibleLogSizeUnitValues returns an array of possible values for the LogSizeUnit const type. +func PossibleLogSizeUnitValues() []LogSizeUnit { + return []LogSizeUnit{Gigabytes, Megabytes, Percent, Petabytes, Terabytes} +} + +// LongTermRetentionDatabaseState enumerates the values for long term retention database state. +type LongTermRetentionDatabaseState string + +const ( + // LongTermRetentionDatabaseStateAll ... + LongTermRetentionDatabaseStateAll LongTermRetentionDatabaseState = "All" + // LongTermRetentionDatabaseStateDeleted ... + LongTermRetentionDatabaseStateDeleted LongTermRetentionDatabaseState = "Deleted" + // LongTermRetentionDatabaseStateLive ... + LongTermRetentionDatabaseStateLive LongTermRetentionDatabaseState = "Live" +) + +// PossibleLongTermRetentionDatabaseStateValues returns an array of possible values for the LongTermRetentionDatabaseState const type. +func PossibleLongTermRetentionDatabaseStateValues() []LongTermRetentionDatabaseState { + return []LongTermRetentionDatabaseState{LongTermRetentionDatabaseStateAll, LongTermRetentionDatabaseStateDeleted, LongTermRetentionDatabaseStateLive} +} + +// ManagedDatabaseCreateMode enumerates the values for managed database create mode. +type ManagedDatabaseCreateMode string + +const ( + // ManagedDatabaseCreateModeDefault ... + ManagedDatabaseCreateModeDefault ManagedDatabaseCreateMode = "Default" + // ManagedDatabaseCreateModePointInTimeRestore ... + ManagedDatabaseCreateModePointInTimeRestore ManagedDatabaseCreateMode = "PointInTimeRestore" + // ManagedDatabaseCreateModeRecovery ... + ManagedDatabaseCreateModeRecovery ManagedDatabaseCreateMode = "Recovery" + // ManagedDatabaseCreateModeRestoreExternalBackup ... + ManagedDatabaseCreateModeRestoreExternalBackup ManagedDatabaseCreateMode = "RestoreExternalBackup" + // ManagedDatabaseCreateModeRestoreLongTermRetentionBackup ... + ManagedDatabaseCreateModeRestoreLongTermRetentionBackup ManagedDatabaseCreateMode = "RestoreLongTermRetentionBackup" +) + +// PossibleManagedDatabaseCreateModeValues returns an array of possible values for the ManagedDatabaseCreateMode const type. +func PossibleManagedDatabaseCreateModeValues() []ManagedDatabaseCreateMode { + return []ManagedDatabaseCreateMode{ManagedDatabaseCreateModeDefault, ManagedDatabaseCreateModePointInTimeRestore, ManagedDatabaseCreateModeRecovery, ManagedDatabaseCreateModeRestoreExternalBackup, ManagedDatabaseCreateModeRestoreLongTermRetentionBackup} +} + +// ManagedDatabaseStatus enumerates the values for managed database status. +type ManagedDatabaseStatus string + +const ( + // Creating ... + Creating ManagedDatabaseStatus = "Creating" + // Inaccessible ... + Inaccessible ManagedDatabaseStatus = "Inaccessible" + // Offline ... + Offline ManagedDatabaseStatus = "Offline" + // Online ... + Online ManagedDatabaseStatus = "Online" + // Restoring ... + Restoring ManagedDatabaseStatus = "Restoring" + // Shutdown ... + Shutdown ManagedDatabaseStatus = "Shutdown" + // Updating ... + Updating ManagedDatabaseStatus = "Updating" +) + +// PossibleManagedDatabaseStatusValues returns an array of possible values for the ManagedDatabaseStatus const type. +func PossibleManagedDatabaseStatusValues() []ManagedDatabaseStatus { + return []ManagedDatabaseStatus{Creating, Inaccessible, Offline, Online, Restoring, Shutdown, Updating} +} + +// ManagedInstanceLicenseType enumerates the values for managed instance license type. +type ManagedInstanceLicenseType string + +const ( + // ManagedInstanceLicenseTypeBasePrice ... + ManagedInstanceLicenseTypeBasePrice ManagedInstanceLicenseType = "BasePrice" + // ManagedInstanceLicenseTypeLicenseIncluded ... + ManagedInstanceLicenseTypeLicenseIncluded ManagedInstanceLicenseType = "LicenseIncluded" +) + +// PossibleManagedInstanceLicenseTypeValues returns an array of possible values for the ManagedInstanceLicenseType const type. +func PossibleManagedInstanceLicenseTypeValues() []ManagedInstanceLicenseType { + return []ManagedInstanceLicenseType{ManagedInstanceLicenseTypeBasePrice, ManagedInstanceLicenseTypeLicenseIncluded} +} + +// ManagedInstanceProxyOverride enumerates the values for managed instance proxy override. +type ManagedInstanceProxyOverride string + +const ( + // ManagedInstanceProxyOverrideDefault ... + ManagedInstanceProxyOverrideDefault ManagedInstanceProxyOverride = "Default" + // ManagedInstanceProxyOverrideProxy ... + ManagedInstanceProxyOverrideProxy ManagedInstanceProxyOverride = "Proxy" + // ManagedInstanceProxyOverrideRedirect ... + ManagedInstanceProxyOverrideRedirect ManagedInstanceProxyOverride = "Redirect" +) + +// PossibleManagedInstanceProxyOverrideValues returns an array of possible values for the ManagedInstanceProxyOverride const type. +func PossibleManagedInstanceProxyOverrideValues() []ManagedInstanceProxyOverride { + return []ManagedInstanceProxyOverride{ManagedInstanceProxyOverrideDefault, ManagedInstanceProxyOverrideProxy, ManagedInstanceProxyOverrideRedirect} +} + +// ManagedServerCreateMode enumerates the values for managed server create mode. +type ManagedServerCreateMode string + +const ( + // ManagedServerCreateModeDefault ... + ManagedServerCreateModeDefault ManagedServerCreateMode = "Default" + // ManagedServerCreateModePointInTimeRestore ... + ManagedServerCreateModePointInTimeRestore ManagedServerCreateMode = "PointInTimeRestore" +) + +// PossibleManagedServerCreateModeValues returns an array of possible values for the ManagedServerCreateMode const type. +func PossibleManagedServerCreateModeValues() []ManagedServerCreateMode { + return []ManagedServerCreateMode{ManagedServerCreateModeDefault, ManagedServerCreateModePointInTimeRestore} +} + +// 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" +) + +// PossibleManagementOperationStateValues returns an array of possible values for the ManagementOperationState const type. +func PossibleManagementOperationStateValues() []ManagementOperationState { + return []ManagementOperationState{ManagementOperationStateCancelInProgress, ManagementOperationStateCancelled, ManagementOperationStateFailed, ManagementOperationStateInProgress, ManagementOperationStatePending, ManagementOperationStateSucceeded} +} + +// MaxSizeUnit enumerates the values for max size unit. +type MaxSizeUnit string + +const ( + // MaxSizeUnitGigabytes ... + MaxSizeUnitGigabytes MaxSizeUnit = "Gigabytes" + // MaxSizeUnitMegabytes ... + MaxSizeUnitMegabytes MaxSizeUnit = "Megabytes" + // MaxSizeUnitPetabytes ... + MaxSizeUnitPetabytes MaxSizeUnit = "Petabytes" + // MaxSizeUnitTerabytes ... + MaxSizeUnitTerabytes MaxSizeUnit = "Terabytes" +) + +// PossibleMaxSizeUnitValues returns an array of possible values for the MaxSizeUnit const type. +func PossibleMaxSizeUnitValues() []MaxSizeUnit { + return []MaxSizeUnit{MaxSizeUnitGigabytes, MaxSizeUnitMegabytes, MaxSizeUnitPetabytes, MaxSizeUnitTerabytes} +} + +// MetricType enumerates the values for metric type. +type MetricType string + +const ( + // CPU ... + CPU MetricType = "cpu" + // Dtu ... + Dtu MetricType = "dtu" + // Duration ... + Duration MetricType = "duration" + // Io ... + Io MetricType = "io" + // LogIo ... + LogIo MetricType = "logIo" +) + +// PossibleMetricTypeValues returns an array of possible values for the MetricType const type. +func PossibleMetricTypeValues() []MetricType { + return []MetricType{CPU, Dtu, Duration, Io, LogIo} +} + +// OperationOrigin enumerates the values for operation origin. +type OperationOrigin string + +const ( + // System ... + System OperationOrigin = "system" + // User ... + User OperationOrigin = "user" +) + +// PossibleOperationOriginValues returns an array of possible values for the OperationOrigin const type. +func PossibleOperationOriginValues() []OperationOrigin { + return []OperationOrigin{System, User} +} + +// PauseDelayTimeUnit enumerates the values for pause delay time unit. +type PauseDelayTimeUnit string + +const ( + // Minutes ... + Minutes PauseDelayTimeUnit = "Minutes" +) + +// PossiblePauseDelayTimeUnitValues returns an array of possible values for the PauseDelayTimeUnit const type. +func PossiblePauseDelayTimeUnitValues() []PauseDelayTimeUnit { + return []PauseDelayTimeUnit{Minutes} +} + +// PerformanceLevelUnit enumerates the values for performance level unit. +type PerformanceLevelUnit string + +const ( + // DTU ... + DTU PerformanceLevelUnit = "DTU" + // VCores ... + VCores PerformanceLevelUnit = "VCores" +) + +// PossiblePerformanceLevelUnitValues returns an array of possible values for the PerformanceLevelUnit const type. +func PossiblePerformanceLevelUnitValues() []PerformanceLevelUnit { + return []PerformanceLevelUnit{DTU, VCores} +} + +// PrimaryAggregationType enumerates the values for primary aggregation type. +type PrimaryAggregationType string + +const ( + // PrimaryAggregationTypeAverage ... + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + // PrimaryAggregationTypeCount ... + PrimaryAggregationTypeCount PrimaryAggregationType = "Count" + // PrimaryAggregationTypeMaximum ... + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + // PrimaryAggregationTypeMinimum ... + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + // PrimaryAggregationTypeNone ... + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + // PrimaryAggregationTypeTotal ... + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" +) + +// PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. +func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { + return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeCount, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} +} + +// PrivateEndpointProvisioningState enumerates the values for private endpoint provisioning state. +type PrivateEndpointProvisioningState string + +const ( + // PrivateEndpointProvisioningStateApproving ... + PrivateEndpointProvisioningStateApproving PrivateEndpointProvisioningState = "Approving" + // PrivateEndpointProvisioningStateDropping ... + PrivateEndpointProvisioningStateDropping PrivateEndpointProvisioningState = "Dropping" + // PrivateEndpointProvisioningStateFailed ... + PrivateEndpointProvisioningStateFailed PrivateEndpointProvisioningState = "Failed" + // PrivateEndpointProvisioningStateReady ... + PrivateEndpointProvisioningStateReady PrivateEndpointProvisioningState = "Ready" + // PrivateEndpointProvisioningStateRejecting ... + PrivateEndpointProvisioningStateRejecting PrivateEndpointProvisioningState = "Rejecting" +) + +// PossiblePrivateEndpointProvisioningStateValues returns an array of possible values for the PrivateEndpointProvisioningState const type. +func PossiblePrivateEndpointProvisioningStateValues() []PrivateEndpointProvisioningState { + return []PrivateEndpointProvisioningState{PrivateEndpointProvisioningStateApproving, PrivateEndpointProvisioningStateDropping, PrivateEndpointProvisioningStateFailed, PrivateEndpointProvisioningStateReady, PrivateEndpointProvisioningStateRejecting} +} + +// PrivateLinkServiceConnectionStateActionsRequire enumerates the values for private link service connection +// state actions require. +type PrivateLinkServiceConnectionStateActionsRequire string + +const ( + // PrivateLinkServiceConnectionStateActionsRequireNone ... + PrivateLinkServiceConnectionStateActionsRequireNone PrivateLinkServiceConnectionStateActionsRequire = "None" +) + +// PossiblePrivateLinkServiceConnectionStateActionsRequireValues returns an array of possible values for the PrivateLinkServiceConnectionStateActionsRequire const type. +func PossiblePrivateLinkServiceConnectionStateActionsRequireValues() []PrivateLinkServiceConnectionStateActionsRequire { + return []PrivateLinkServiceConnectionStateActionsRequire{PrivateLinkServiceConnectionStateActionsRequireNone} +} + +// PrivateLinkServiceConnectionStateStatus enumerates the values for private link service connection state +// status. +type PrivateLinkServiceConnectionStateStatus string + +const ( + // Approved ... + Approved PrivateLinkServiceConnectionStateStatus = "Approved" + // Disconnected ... + Disconnected PrivateLinkServiceConnectionStateStatus = "Disconnected" + // Pending ... + Pending PrivateLinkServiceConnectionStateStatus = "Pending" + // Rejected ... + Rejected PrivateLinkServiceConnectionStateStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStateStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStateStatus const type. +func PossiblePrivateLinkServiceConnectionStateStatusValues() []PrivateLinkServiceConnectionStateStatus { + return []PrivateLinkServiceConnectionStateStatus{Approved, Disconnected, Pending, Rejected} +} + +// 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" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateCreated, ProvisioningStateFailed, ProvisioningStateInProgress, ProvisioningStateSucceeded} +} + +// ProvisioningState1 enumerates the values for provisioning state 1. +type ProvisioningState1 string + +const ( + // ProvisioningState1Creating ... + ProvisioningState1Creating ProvisioningState1 = "Creating" + // ProvisioningState1Deleting ... + ProvisioningState1Deleting ProvisioningState1 = "Deleting" + // ProvisioningState1Failed ... + ProvisioningState1Failed ProvisioningState1 = "Failed" + // ProvisioningState1Succeeded ... + ProvisioningState1Succeeded ProvisioningState1 = "Succeeded" + // ProvisioningState1Unknown ... + ProvisioningState1Unknown ProvisioningState1 = "Unknown" + // ProvisioningState1Updating ... + ProvisioningState1Updating ProvisioningState1 = "Updating" +) + +// PossibleProvisioningState1Values returns an array of possible values for the ProvisioningState1 const type. +func PossibleProvisioningState1Values() []ProvisioningState1 { + return []ProvisioningState1{ProvisioningState1Creating, ProvisioningState1Deleting, ProvisioningState1Failed, ProvisioningState1Succeeded, ProvisioningState1Unknown, ProvisioningState1Updating} +} + +// QueryMetricUnitType enumerates the values for query metric unit type. +type QueryMetricUnitType string + +const ( + // Count ... + Count QueryMetricUnitType = "count" + // KB ... + KB QueryMetricUnitType = "KB" + // Microseconds ... + Microseconds QueryMetricUnitType = "microseconds" + // Percentage ... + Percentage QueryMetricUnitType = "percentage" +) + +// PossibleQueryMetricUnitTypeValues returns an array of possible values for the QueryMetricUnitType const type. +func PossibleQueryMetricUnitTypeValues() []QueryMetricUnitType { + return []QueryMetricUnitType{Count, KB, Microseconds, Percentage} +} + +// QueryTimeGrainType enumerates the values for query time grain type. +type QueryTimeGrainType string + +const ( + // P1D ... + P1D QueryTimeGrainType = "P1D" + // PT1H ... + PT1H QueryTimeGrainType = "PT1H" +) + +// PossibleQueryTimeGrainTypeValues returns an array of possible values for the QueryTimeGrainType const type. +func PossibleQueryTimeGrainTypeValues() []QueryTimeGrainType { + return []QueryTimeGrainType{P1D, PT1H} +} + +// ReadOnlyEndpointFailoverPolicy enumerates the values for read only endpoint failover policy. +type ReadOnlyEndpointFailoverPolicy string + +const ( + // ReadOnlyEndpointFailoverPolicyDisabled ... + ReadOnlyEndpointFailoverPolicyDisabled ReadOnlyEndpointFailoverPolicy = "Disabled" + // ReadOnlyEndpointFailoverPolicyEnabled ... + ReadOnlyEndpointFailoverPolicyEnabled ReadOnlyEndpointFailoverPolicy = "Enabled" +) + +// PossibleReadOnlyEndpointFailoverPolicyValues returns an array of possible values for the ReadOnlyEndpointFailoverPolicy const type. +func PossibleReadOnlyEndpointFailoverPolicyValues() []ReadOnlyEndpointFailoverPolicy { + return []ReadOnlyEndpointFailoverPolicy{ReadOnlyEndpointFailoverPolicyDisabled, ReadOnlyEndpointFailoverPolicyEnabled} +} + +// ReadWriteEndpointFailoverPolicy enumerates the values for read write endpoint failover policy. +type ReadWriteEndpointFailoverPolicy string + +const ( + // Automatic ... + Automatic ReadWriteEndpointFailoverPolicy = "Automatic" + // Manual ... + Manual ReadWriteEndpointFailoverPolicy = "Manual" +) + +// PossibleReadWriteEndpointFailoverPolicyValues returns an array of possible values for the ReadWriteEndpointFailoverPolicy const type. +func PossibleReadWriteEndpointFailoverPolicyValues() []ReadWriteEndpointFailoverPolicy { + return []ReadWriteEndpointFailoverPolicy{Automatic, Manual} +} + +// RecommendedIndexAction enumerates the values for recommended index action. +type RecommendedIndexAction string + +const ( + // Create ... + Create RecommendedIndexAction = "Create" + // Drop ... + Drop RecommendedIndexAction = "Drop" + // Rebuild ... + Rebuild RecommendedIndexAction = "Rebuild" +) + +// PossibleRecommendedIndexActionValues returns an array of possible values for the RecommendedIndexAction const type. +func PossibleRecommendedIndexActionValues() []RecommendedIndexAction { + return []RecommendedIndexAction{Create, Drop, Rebuild} +} + +// RecommendedIndexState enumerates the values for recommended index state. +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" +) + +// PossibleRecommendedIndexStateValues returns an array of possible values for the RecommendedIndexState const type. +func PossibleRecommendedIndexStateValues() []RecommendedIndexState { + return []RecommendedIndexState{RecommendedIndexStateActive, RecommendedIndexStateBlocked, RecommendedIndexStateExecuting, RecommendedIndexStateExpired, RecommendedIndexStateIgnored, RecommendedIndexStatePending, RecommendedIndexStatePendingRevert, RecommendedIndexStateReverted, RecommendedIndexStateReverting, RecommendedIndexStateSuccess, RecommendedIndexStateVerifying} +} + +// RecommendedIndexType enumerates the values for recommended index type. +type RecommendedIndexType string + +const ( + // CLUSTERED ... + CLUSTERED RecommendedIndexType = "CLUSTERED" + // CLUSTEREDCOLUMNSTORE ... + CLUSTEREDCOLUMNSTORE RecommendedIndexType = "CLUSTERED COLUMNSTORE" + // COLUMNSTORE ... + COLUMNSTORE RecommendedIndexType = "COLUMNSTORE" + // NONCLUSTERED ... + NONCLUSTERED RecommendedIndexType = "NONCLUSTERED" +) + +// PossibleRecommendedIndexTypeValues returns an array of possible values for the RecommendedIndexType const type. +func PossibleRecommendedIndexTypeValues() []RecommendedIndexType { + return []RecommendedIndexType{CLUSTERED, CLUSTEREDCOLUMNSTORE, COLUMNSTORE, NONCLUSTERED} +} + +// ReplicationRole enumerates the values for replication role. +type ReplicationRole string + +const ( + // ReplicationRoleCopy ... + ReplicationRoleCopy ReplicationRole = "Copy" + // ReplicationRoleNonReadableSecondary ... + ReplicationRoleNonReadableSecondary ReplicationRole = "NonReadableSecondary" + // ReplicationRolePrimary ... + ReplicationRolePrimary ReplicationRole = "Primary" + // ReplicationRoleSecondary ... + ReplicationRoleSecondary ReplicationRole = "Secondary" + // ReplicationRoleSource ... + ReplicationRoleSource ReplicationRole = "Source" +) + +// PossibleReplicationRoleValues returns an array of possible values for the ReplicationRole const type. +func PossibleReplicationRoleValues() []ReplicationRole { + return []ReplicationRole{ReplicationRoleCopy, ReplicationRoleNonReadableSecondary, ReplicationRolePrimary, ReplicationRoleSecondary, ReplicationRoleSource} +} + +// ReplicationState enumerates the values for replication state. +type ReplicationState string + +const ( + // CATCHUP ... + CATCHUP ReplicationState = "CATCH_UP" + // PENDING ... + PENDING ReplicationState = "PENDING" + // SEEDING ... + SEEDING ReplicationState = "SEEDING" + // SUSPENDED ... + SUSPENDED ReplicationState = "SUSPENDED" +) + +// PossibleReplicationStateValues returns an array of possible values for the ReplicationState const type. +func PossibleReplicationStateValues() []ReplicationState { + return []ReplicationState{CATCHUP, PENDING, SEEDING, SUSPENDED} +} + +// ReplicaType enumerates the values for replica type. +type ReplicaType string + +const ( + // ReplicaTypePrimary ... + ReplicaTypePrimary ReplicaType = "Primary" + // ReplicaTypeReadableSecondary ... + ReplicaTypeReadableSecondary ReplicaType = "ReadableSecondary" +) + +// PossibleReplicaTypeValues returns an array of possible values for the ReplicaType const type. +func PossibleReplicaTypeValues() []ReplicaType { + return []ReplicaType{ReplicaTypePrimary, ReplicaTypeReadableSecondary} +} + +// RestorePointType enumerates the values for restore point type. +type RestorePointType string + +const ( + // CONTINUOUS ... + CONTINUOUS RestorePointType = "CONTINUOUS" + // DISCRETE ... + DISCRETE RestorePointType = "DISCRETE" +) + +// PossibleRestorePointTypeValues returns an array of possible values for the RestorePointType const type. +func PossibleRestorePointTypeValues() []RestorePointType { + return []RestorePointType{CONTINUOUS, DISCRETE} +} + +// SampleName enumerates the values for sample name. +type SampleName string + +const ( + // AdventureWorksLT ... + AdventureWorksLT SampleName = "AdventureWorksLT" + // WideWorldImportersFull ... + WideWorldImportersFull SampleName = "WideWorldImportersFull" + // WideWorldImportersStd ... + WideWorldImportersStd SampleName = "WideWorldImportersStd" +) + +// PossibleSampleNameValues returns an array of possible values for the SampleName const type. +func PossibleSampleNameValues() []SampleName { + return []SampleName{AdventureWorksLT, WideWorldImportersFull, WideWorldImportersStd} +} + +// SecurityAlertPolicyEmailAccountAdmins enumerates the values for security alert policy email account admins. +type SecurityAlertPolicyEmailAccountAdmins string + +const ( + // SecurityAlertPolicyEmailAccountAdminsDisabled ... + SecurityAlertPolicyEmailAccountAdminsDisabled SecurityAlertPolicyEmailAccountAdmins = "Disabled" + // SecurityAlertPolicyEmailAccountAdminsEnabled ... + SecurityAlertPolicyEmailAccountAdminsEnabled SecurityAlertPolicyEmailAccountAdmins = "Enabled" +) + +// PossibleSecurityAlertPolicyEmailAccountAdminsValues returns an array of possible values for the SecurityAlertPolicyEmailAccountAdmins const type. +func PossibleSecurityAlertPolicyEmailAccountAdminsValues() []SecurityAlertPolicyEmailAccountAdmins { + return []SecurityAlertPolicyEmailAccountAdmins{SecurityAlertPolicyEmailAccountAdminsDisabled, SecurityAlertPolicyEmailAccountAdminsEnabled} +} + +// SecurityAlertPolicyState enumerates the values for security alert policy state. +type SecurityAlertPolicyState string + +const ( + // SecurityAlertPolicyStateDisabled ... + SecurityAlertPolicyStateDisabled SecurityAlertPolicyState = "Disabled" + // SecurityAlertPolicyStateEnabled ... + SecurityAlertPolicyStateEnabled SecurityAlertPolicyState = "Enabled" + // SecurityAlertPolicyStateNew ... + SecurityAlertPolicyStateNew SecurityAlertPolicyState = "New" +) + +// PossibleSecurityAlertPolicyStateValues returns an array of possible values for the SecurityAlertPolicyState const type. +func PossibleSecurityAlertPolicyStateValues() []SecurityAlertPolicyState { + return []SecurityAlertPolicyState{SecurityAlertPolicyStateDisabled, SecurityAlertPolicyStateEnabled, SecurityAlertPolicyStateNew} +} + +// SecurityAlertPolicyUseServerDefault enumerates the values for security alert policy use server default. +type SecurityAlertPolicyUseServerDefault string + +const ( + // SecurityAlertPolicyUseServerDefaultDisabled ... + SecurityAlertPolicyUseServerDefaultDisabled SecurityAlertPolicyUseServerDefault = "Disabled" + // SecurityAlertPolicyUseServerDefaultEnabled ... + SecurityAlertPolicyUseServerDefaultEnabled SecurityAlertPolicyUseServerDefault = "Enabled" +) + +// PossibleSecurityAlertPolicyUseServerDefaultValues returns an array of possible values for the SecurityAlertPolicyUseServerDefault const type. +func PossibleSecurityAlertPolicyUseServerDefaultValues() []SecurityAlertPolicyUseServerDefault { + return []SecurityAlertPolicyUseServerDefault{SecurityAlertPolicyUseServerDefaultDisabled, SecurityAlertPolicyUseServerDefaultEnabled} +} + +// SensitivityLabelRank enumerates the values for sensitivity label rank. +type SensitivityLabelRank string + +const ( + // SensitivityLabelRankCritical ... + SensitivityLabelRankCritical SensitivityLabelRank = "Critical" + // SensitivityLabelRankHigh ... + SensitivityLabelRankHigh SensitivityLabelRank = "High" + // SensitivityLabelRankLow ... + SensitivityLabelRankLow SensitivityLabelRank = "Low" + // SensitivityLabelRankMedium ... + SensitivityLabelRankMedium SensitivityLabelRank = "Medium" + // SensitivityLabelRankNone ... + SensitivityLabelRankNone SensitivityLabelRank = "None" +) + +// PossibleSensitivityLabelRankValues returns an array of possible values for the SensitivityLabelRank const type. +func PossibleSensitivityLabelRankValues() []SensitivityLabelRank { + return []SensitivityLabelRank{SensitivityLabelRankCritical, SensitivityLabelRankHigh, SensitivityLabelRankLow, SensitivityLabelRankMedium, SensitivityLabelRankNone} +} + +// SensitivityLabelSource enumerates the values for sensitivity label source. +type SensitivityLabelSource string + +const ( + // Current ... + Current SensitivityLabelSource = "current" + // Recommended ... + Recommended SensitivityLabelSource = "recommended" +) + +// PossibleSensitivityLabelSourceValues returns an array of possible values for the SensitivityLabelSource const type. +func PossibleSensitivityLabelSourceValues() []SensitivityLabelSource { + return []SensitivityLabelSource{Current, Recommended} +} + +// ServerConnectionType enumerates the values for server connection type. +type ServerConnectionType string + +const ( + // ServerConnectionTypeDefault ... + ServerConnectionTypeDefault ServerConnectionType = "Default" + // ServerConnectionTypeProxy ... + ServerConnectionTypeProxy ServerConnectionType = "Proxy" + // ServerConnectionTypeRedirect ... + ServerConnectionTypeRedirect ServerConnectionType = "Redirect" +) + +// PossibleServerConnectionTypeValues returns an array of possible values for the ServerConnectionType const type. +func PossibleServerConnectionTypeValues() []ServerConnectionType { + return []ServerConnectionType{ServerConnectionTypeDefault, ServerConnectionTypeProxy, ServerConnectionTypeRedirect} +} + +// ServerKeyType enumerates the values for server key type. +type ServerKeyType string + +const ( + // AzureKeyVault ... + AzureKeyVault ServerKeyType = "AzureKeyVault" + // ServiceManaged ... + ServiceManaged ServerKeyType = "ServiceManaged" +) + +// PossibleServerKeyTypeValues returns an array of possible values for the ServerKeyType const type. +func PossibleServerKeyTypeValues() []ServerKeyType { + return []ServerKeyType{AzureKeyVault, ServiceManaged} +} + +// ServerPublicNetworkAccess enumerates the values for server public network access. +type ServerPublicNetworkAccess string + +const ( + // ServerPublicNetworkAccessDisabled ... + ServerPublicNetworkAccessDisabled ServerPublicNetworkAccess = "Disabled" + // ServerPublicNetworkAccessEnabled ... + ServerPublicNetworkAccessEnabled ServerPublicNetworkAccess = "Enabled" +) + +// PossibleServerPublicNetworkAccessValues returns an array of possible values for the ServerPublicNetworkAccess const type. +func PossibleServerPublicNetworkAccessValues() []ServerPublicNetworkAccess { + return []ServerPublicNetworkAccess{ServerPublicNetworkAccessDisabled, ServerPublicNetworkAccessEnabled} +} + +// ServiceObjectiveName enumerates the values for service objective name. +type ServiceObjectiveName string + +const ( + // ServiceObjectiveNameBasic ... + ServiceObjectiveNameBasic ServiceObjectiveName = "Basic" + // ServiceObjectiveNameDS100 ... + ServiceObjectiveNameDS100 ServiceObjectiveName = "DS100" + // ServiceObjectiveNameDS1000 ... + ServiceObjectiveNameDS1000 ServiceObjectiveName = "DS1000" + // ServiceObjectiveNameDS1200 ... + ServiceObjectiveNameDS1200 ServiceObjectiveName = "DS1200" + // ServiceObjectiveNameDS1500 ... + ServiceObjectiveNameDS1500 ServiceObjectiveName = "DS1500" + // ServiceObjectiveNameDS200 ... + ServiceObjectiveNameDS200 ServiceObjectiveName = "DS200" + // ServiceObjectiveNameDS2000 ... + ServiceObjectiveNameDS2000 ServiceObjectiveName = "DS2000" + // ServiceObjectiveNameDS300 ... + ServiceObjectiveNameDS300 ServiceObjectiveName = "DS300" + // ServiceObjectiveNameDS400 ... + ServiceObjectiveNameDS400 ServiceObjectiveName = "DS400" + // ServiceObjectiveNameDS500 ... + ServiceObjectiveNameDS500 ServiceObjectiveName = "DS500" + // ServiceObjectiveNameDS600 ... + ServiceObjectiveNameDS600 ServiceObjectiveName = "DS600" + // ServiceObjectiveNameDW100 ... + ServiceObjectiveNameDW100 ServiceObjectiveName = "DW100" + // ServiceObjectiveNameDW1000 ... + ServiceObjectiveNameDW1000 ServiceObjectiveName = "DW1000" + // ServiceObjectiveNameDW10000c ... + ServiceObjectiveNameDW10000c ServiceObjectiveName = "DW10000c" + // ServiceObjectiveNameDW1000c ... + ServiceObjectiveNameDW1000c ServiceObjectiveName = "DW1000c" + // ServiceObjectiveNameDW1200 ... + ServiceObjectiveNameDW1200 ServiceObjectiveName = "DW1200" + // ServiceObjectiveNameDW1500 ... + ServiceObjectiveNameDW1500 ServiceObjectiveName = "DW1500" + // ServiceObjectiveNameDW15000c ... + ServiceObjectiveNameDW15000c ServiceObjectiveName = "DW15000c" + // ServiceObjectiveNameDW1500c ... + ServiceObjectiveNameDW1500c ServiceObjectiveName = "DW1500c" + // ServiceObjectiveNameDW200 ... + ServiceObjectiveNameDW200 ServiceObjectiveName = "DW200" + // ServiceObjectiveNameDW2000 ... + ServiceObjectiveNameDW2000 ServiceObjectiveName = "DW2000" + // ServiceObjectiveNameDW2000c ... + ServiceObjectiveNameDW2000c ServiceObjectiveName = "DW2000c" + // ServiceObjectiveNameDW2500c ... + ServiceObjectiveNameDW2500c ServiceObjectiveName = "DW2500c" + // ServiceObjectiveNameDW300 ... + ServiceObjectiveNameDW300 ServiceObjectiveName = "DW300" + // ServiceObjectiveNameDW3000 ... + ServiceObjectiveNameDW3000 ServiceObjectiveName = "DW3000" + // ServiceObjectiveNameDW30000c ... + ServiceObjectiveNameDW30000c ServiceObjectiveName = "DW30000c" + // ServiceObjectiveNameDW3000c ... + ServiceObjectiveNameDW3000c ServiceObjectiveName = "DW3000c" + // ServiceObjectiveNameDW400 ... + ServiceObjectiveNameDW400 ServiceObjectiveName = "DW400" + // ServiceObjectiveNameDW500 ... + ServiceObjectiveNameDW500 ServiceObjectiveName = "DW500" + // ServiceObjectiveNameDW5000c ... + ServiceObjectiveNameDW5000c ServiceObjectiveName = "DW5000c" + // ServiceObjectiveNameDW600 ... + ServiceObjectiveNameDW600 ServiceObjectiveName = "DW600" + // ServiceObjectiveNameDW6000 ... + ServiceObjectiveNameDW6000 ServiceObjectiveName = "DW6000" + // ServiceObjectiveNameDW6000c ... + ServiceObjectiveNameDW6000c ServiceObjectiveName = "DW6000c" + // ServiceObjectiveNameDW7500c ... + ServiceObjectiveNameDW7500c ServiceObjectiveName = "DW7500c" + // ServiceObjectiveNameElasticPool ... + ServiceObjectiveNameElasticPool ServiceObjectiveName = "ElasticPool" + // ServiceObjectiveNameFree ... + ServiceObjectiveNameFree ServiceObjectiveName = "Free" + // ServiceObjectiveNameP1 ... + ServiceObjectiveNameP1 ServiceObjectiveName = "P1" + // ServiceObjectiveNameP11 ... + ServiceObjectiveNameP11 ServiceObjectiveName = "P11" + // ServiceObjectiveNameP15 ... + ServiceObjectiveNameP15 ServiceObjectiveName = "P15" + // ServiceObjectiveNameP2 ... + ServiceObjectiveNameP2 ServiceObjectiveName = "P2" + // ServiceObjectiveNameP3 ... + ServiceObjectiveNameP3 ServiceObjectiveName = "P3" + // ServiceObjectiveNameP4 ... + ServiceObjectiveNameP4 ServiceObjectiveName = "P4" + // ServiceObjectiveNameP6 ... + ServiceObjectiveNameP6 ServiceObjectiveName = "P6" + // ServiceObjectiveNamePRS1 ... + ServiceObjectiveNamePRS1 ServiceObjectiveName = "PRS1" + // ServiceObjectiveNamePRS2 ... + ServiceObjectiveNamePRS2 ServiceObjectiveName = "PRS2" + // ServiceObjectiveNamePRS4 ... + ServiceObjectiveNamePRS4 ServiceObjectiveName = "PRS4" + // ServiceObjectiveNamePRS6 ... + ServiceObjectiveNamePRS6 ServiceObjectiveName = "PRS6" + // ServiceObjectiveNameS0 ... + ServiceObjectiveNameS0 ServiceObjectiveName = "S0" + // ServiceObjectiveNameS1 ... + ServiceObjectiveNameS1 ServiceObjectiveName = "S1" + // ServiceObjectiveNameS12 ... + ServiceObjectiveNameS12 ServiceObjectiveName = "S12" + // ServiceObjectiveNameS2 ... + ServiceObjectiveNameS2 ServiceObjectiveName = "S2" + // ServiceObjectiveNameS3 ... + ServiceObjectiveNameS3 ServiceObjectiveName = "S3" + // ServiceObjectiveNameS4 ... + ServiceObjectiveNameS4 ServiceObjectiveName = "S4" + // ServiceObjectiveNameS6 ... + ServiceObjectiveNameS6 ServiceObjectiveName = "S6" + // ServiceObjectiveNameS7 ... + ServiceObjectiveNameS7 ServiceObjectiveName = "S7" + // ServiceObjectiveNameS9 ... + ServiceObjectiveNameS9 ServiceObjectiveName = "S9" + // ServiceObjectiveNameSystem ... + ServiceObjectiveNameSystem ServiceObjectiveName = "System" + // ServiceObjectiveNameSystem0 ... + ServiceObjectiveNameSystem0 ServiceObjectiveName = "System0" + // ServiceObjectiveNameSystem1 ... + ServiceObjectiveNameSystem1 ServiceObjectiveName = "System1" + // ServiceObjectiveNameSystem2 ... + ServiceObjectiveNameSystem2 ServiceObjectiveName = "System2" + // ServiceObjectiveNameSystem2L ... + ServiceObjectiveNameSystem2L ServiceObjectiveName = "System2L" + // ServiceObjectiveNameSystem3 ... + ServiceObjectiveNameSystem3 ServiceObjectiveName = "System3" + // ServiceObjectiveNameSystem3L ... + ServiceObjectiveNameSystem3L ServiceObjectiveName = "System3L" + // ServiceObjectiveNameSystem4 ... + ServiceObjectiveNameSystem4 ServiceObjectiveName = "System4" + // ServiceObjectiveNameSystem4L ... + ServiceObjectiveNameSystem4L ServiceObjectiveName = "System4L" +) + +// PossibleServiceObjectiveNameValues returns an array of possible values for the ServiceObjectiveName const type. +func PossibleServiceObjectiveNameValues() []ServiceObjectiveName { + return []ServiceObjectiveName{ServiceObjectiveNameBasic, ServiceObjectiveNameDS100, ServiceObjectiveNameDS1000, ServiceObjectiveNameDS1200, ServiceObjectiveNameDS1500, ServiceObjectiveNameDS200, ServiceObjectiveNameDS2000, ServiceObjectiveNameDS300, ServiceObjectiveNameDS400, ServiceObjectiveNameDS500, ServiceObjectiveNameDS600, ServiceObjectiveNameDW100, ServiceObjectiveNameDW1000, ServiceObjectiveNameDW10000c, ServiceObjectiveNameDW1000c, ServiceObjectiveNameDW1200, ServiceObjectiveNameDW1500, ServiceObjectiveNameDW15000c, ServiceObjectiveNameDW1500c, ServiceObjectiveNameDW200, ServiceObjectiveNameDW2000, ServiceObjectiveNameDW2000c, ServiceObjectiveNameDW2500c, ServiceObjectiveNameDW300, ServiceObjectiveNameDW3000, ServiceObjectiveNameDW30000c, ServiceObjectiveNameDW3000c, ServiceObjectiveNameDW400, ServiceObjectiveNameDW500, ServiceObjectiveNameDW5000c, ServiceObjectiveNameDW600, ServiceObjectiveNameDW6000, ServiceObjectiveNameDW6000c, ServiceObjectiveNameDW7500c, ServiceObjectiveNameElasticPool, ServiceObjectiveNameFree, ServiceObjectiveNameP1, ServiceObjectiveNameP11, ServiceObjectiveNameP15, ServiceObjectiveNameP2, ServiceObjectiveNameP3, ServiceObjectiveNameP4, ServiceObjectiveNameP6, ServiceObjectiveNamePRS1, ServiceObjectiveNamePRS2, ServiceObjectiveNamePRS4, ServiceObjectiveNamePRS6, ServiceObjectiveNameS0, ServiceObjectiveNameS1, ServiceObjectiveNameS12, ServiceObjectiveNameS2, ServiceObjectiveNameS3, ServiceObjectiveNameS4, ServiceObjectiveNameS6, ServiceObjectiveNameS7, ServiceObjectiveNameS9, ServiceObjectiveNameSystem, ServiceObjectiveNameSystem0, ServiceObjectiveNameSystem1, ServiceObjectiveNameSystem2, ServiceObjectiveNameSystem2L, ServiceObjectiveNameSystem3, ServiceObjectiveNameSystem3L, ServiceObjectiveNameSystem4, ServiceObjectiveNameSystem4L} +} + +// Status enumerates the values for status. +type Status string + +const ( + // StatusCanceled ... + StatusCanceled Status = "Canceled" + // StatusCompleted ... + StatusCompleted Status = "Completed" + // StatusFailed ... + StatusFailed Status = "Failed" + // StatusInProgress ... + StatusInProgress Status = "InProgress" + // StatusNotStarted ... + StatusNotStarted Status = "NotStarted" + // StatusSlowedDown ... + StatusSlowedDown Status = "SlowedDown" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{StatusCanceled, StatusCompleted, StatusFailed, StatusInProgress, StatusNotStarted, StatusSlowedDown} +} + +// StorageAccountType enumerates the values for storage account type. +type StorageAccountType string + +const ( + // GRS ... + GRS StorageAccountType = "GRS" + // LRS ... + LRS StorageAccountType = "LRS" + // ZRS ... + ZRS StorageAccountType = "ZRS" +) + +// PossibleStorageAccountTypeValues returns an array of possible values for the StorageAccountType const type. +func PossibleStorageAccountTypeValues() []StorageAccountType { + return []StorageAccountType{GRS, LRS, ZRS} +} + +// StorageAccountType1 enumerates the values for storage account type 1. +type StorageAccountType1 string + +const ( + // StorageAccountType1GRS ... + StorageAccountType1GRS StorageAccountType1 = "GRS" + // StorageAccountType1LRS ... + StorageAccountType1LRS StorageAccountType1 = "LRS" + // StorageAccountType1ZRS ... + StorageAccountType1ZRS StorageAccountType1 = "ZRS" +) + +// PossibleStorageAccountType1Values returns an array of possible values for the StorageAccountType1 const type. +func PossibleStorageAccountType1Values() []StorageAccountType1 { + return []StorageAccountType1{StorageAccountType1GRS, StorageAccountType1LRS, StorageAccountType1ZRS} +} + +// StorageKeyType enumerates the values for storage key type. +type StorageKeyType string + +const ( + // SharedAccessKey ... + SharedAccessKey StorageKeyType = "SharedAccessKey" + // StorageAccessKey ... + StorageAccessKey StorageKeyType = "StorageAccessKey" +) + +// PossibleStorageKeyTypeValues returns an array of possible values for the StorageKeyType const type. +func PossibleStorageKeyTypeValues() []StorageKeyType { + return []StorageKeyType{SharedAccessKey, StorageAccessKey} +} + +// SyncAgentState enumerates the values for sync agent state. +type SyncAgentState string + +const ( + // SyncAgentStateNeverConnected ... + SyncAgentStateNeverConnected SyncAgentState = "NeverConnected" + // SyncAgentStateOffline ... + SyncAgentStateOffline SyncAgentState = "Offline" + // SyncAgentStateOnline ... + SyncAgentStateOnline SyncAgentState = "Online" +) + +// PossibleSyncAgentStateValues returns an array of possible values for the SyncAgentState const type. +func PossibleSyncAgentStateValues() []SyncAgentState { + return []SyncAgentState{SyncAgentStateNeverConnected, SyncAgentStateOffline, SyncAgentStateOnline} +} + +// SyncConflictResolutionPolicy enumerates the values for sync conflict resolution policy. +type SyncConflictResolutionPolicy string + +const ( + // HubWin ... + HubWin SyncConflictResolutionPolicy = "HubWin" + // MemberWin ... + MemberWin SyncConflictResolutionPolicy = "MemberWin" +) + +// PossibleSyncConflictResolutionPolicyValues returns an array of possible values for the SyncConflictResolutionPolicy const type. +func PossibleSyncConflictResolutionPolicyValues() []SyncConflictResolutionPolicy { + return []SyncConflictResolutionPolicy{HubWin, MemberWin} +} + +// SyncDirection enumerates the values for sync direction. +type SyncDirection string + +const ( + // Bidirectional ... + Bidirectional SyncDirection = "Bidirectional" + // OneWayHubToMember ... + OneWayHubToMember SyncDirection = "OneWayHubToMember" + // OneWayMemberToHub ... + OneWayMemberToHub SyncDirection = "OneWayMemberToHub" +) + +// PossibleSyncDirectionValues returns an array of possible values for the SyncDirection const type. +func PossibleSyncDirectionValues() []SyncDirection { + return []SyncDirection{Bidirectional, OneWayHubToMember, OneWayMemberToHub} +} + +// SyncGroupLogType enumerates the values for sync group log type. +type SyncGroupLogType string + +const ( + // SyncGroupLogTypeAll ... + SyncGroupLogTypeAll SyncGroupLogType = "All" + // SyncGroupLogTypeError ... + SyncGroupLogTypeError SyncGroupLogType = "Error" + // SyncGroupLogTypeSuccess ... + SyncGroupLogTypeSuccess SyncGroupLogType = "Success" + // SyncGroupLogTypeWarning ... + SyncGroupLogTypeWarning SyncGroupLogType = "Warning" +) + +// PossibleSyncGroupLogTypeValues returns an array of possible values for the SyncGroupLogType const type. +func PossibleSyncGroupLogTypeValues() []SyncGroupLogType { + return []SyncGroupLogType{SyncGroupLogTypeAll, SyncGroupLogTypeError, SyncGroupLogTypeSuccess, SyncGroupLogTypeWarning} +} + +// SyncGroupState enumerates the values for sync group state. +type SyncGroupState string + +const ( + // Error ... + Error SyncGroupState = "Error" + // Good ... + Good SyncGroupState = "Good" + // NotReady ... + NotReady SyncGroupState = "NotReady" + // Progressing ... + Progressing SyncGroupState = "Progressing" + // Warning ... + Warning SyncGroupState = "Warning" +) + +// PossibleSyncGroupStateValues returns an array of possible values for the SyncGroupState const type. +func PossibleSyncGroupStateValues() []SyncGroupState { + return []SyncGroupState{Error, Good, NotReady, Progressing, Warning} +} + +// SyncMemberDbType enumerates the values for sync member db type. +type SyncMemberDbType string + +const ( + // AzureSQLDatabase ... + AzureSQLDatabase SyncMemberDbType = "AzureSqlDatabase" + // SQLServerDatabase ... + SQLServerDatabase SyncMemberDbType = "SqlServerDatabase" +) + +// PossibleSyncMemberDbTypeValues returns an array of possible values for the SyncMemberDbType const type. +func PossibleSyncMemberDbTypeValues() []SyncMemberDbType { + return []SyncMemberDbType{AzureSQLDatabase, SQLServerDatabase} +} + +// SyncMemberState enumerates the values for sync member state. +type SyncMemberState string + +const ( + // DeProvisioned ... + DeProvisioned SyncMemberState = "DeProvisioned" + // DeProvisionFailed ... + DeProvisionFailed SyncMemberState = "DeProvisionFailed" + // DeProvisioning ... + DeProvisioning SyncMemberState = "DeProvisioning" + // DisabledBackupRestore ... + DisabledBackupRestore SyncMemberState = "DisabledBackupRestore" + // DisabledTombstoneCleanup ... + DisabledTombstoneCleanup SyncMemberState = "DisabledTombstoneCleanup" + // Provisioned ... + Provisioned SyncMemberState = "Provisioned" + // ProvisionFailed ... + ProvisionFailed SyncMemberState = "ProvisionFailed" + // Provisioning ... + Provisioning SyncMemberState = "Provisioning" + // ReprovisionFailed ... + ReprovisionFailed SyncMemberState = "ReprovisionFailed" + // Reprovisioning ... + Reprovisioning SyncMemberState = "Reprovisioning" + // SyncCancelled ... + SyncCancelled SyncMemberState = "SyncCancelled" + // SyncCancelling ... + SyncCancelling SyncMemberState = "SyncCancelling" + // SyncFailed ... + SyncFailed SyncMemberState = "SyncFailed" + // SyncInProgress ... + SyncInProgress SyncMemberState = "SyncInProgress" + // SyncSucceeded ... + SyncSucceeded SyncMemberState = "SyncSucceeded" + // SyncSucceededWithWarnings ... + SyncSucceededWithWarnings SyncMemberState = "SyncSucceededWithWarnings" + // UnProvisioned ... + UnProvisioned SyncMemberState = "UnProvisioned" + // UnReprovisioned ... + UnReprovisioned SyncMemberState = "UnReprovisioned" +) + +// PossibleSyncMemberStateValues returns an array of possible values for the SyncMemberState const type. +func PossibleSyncMemberStateValues() []SyncMemberState { + return []SyncMemberState{DeProvisioned, DeProvisionFailed, DeProvisioning, DisabledBackupRestore, DisabledTombstoneCleanup, Provisioned, ProvisionFailed, Provisioning, ReprovisionFailed, Reprovisioning, SyncCancelled, SyncCancelling, SyncFailed, SyncInProgress, SyncSucceeded, SyncSucceededWithWarnings, UnProvisioned, UnReprovisioned} +} + +// TransparentDataEncryptionActivityStatus enumerates the values for transparent data encryption activity +// status. +type TransparentDataEncryptionActivityStatus string + +const ( + // Decrypting ... + Decrypting TransparentDataEncryptionActivityStatus = "Decrypting" + // Encrypting ... + Encrypting TransparentDataEncryptionActivityStatus = "Encrypting" +) + +// PossibleTransparentDataEncryptionActivityStatusValues returns an array of possible values for the TransparentDataEncryptionActivityStatus const type. +func PossibleTransparentDataEncryptionActivityStatusValues() []TransparentDataEncryptionActivityStatus { + return []TransparentDataEncryptionActivityStatus{Decrypting, Encrypting} +} + +// TransparentDataEncryptionStatus enumerates the values for transparent data encryption status. +type TransparentDataEncryptionStatus string + +const ( + // TransparentDataEncryptionStatusDisabled ... + TransparentDataEncryptionStatusDisabled TransparentDataEncryptionStatus = "Disabled" + // TransparentDataEncryptionStatusEnabled ... + TransparentDataEncryptionStatusEnabled TransparentDataEncryptionStatus = "Enabled" +) + +// PossibleTransparentDataEncryptionStatusValues returns an array of possible values for the TransparentDataEncryptionStatus const type. +func PossibleTransparentDataEncryptionStatusValues() []TransparentDataEncryptionStatus { + return []TransparentDataEncryptionStatus{TransparentDataEncryptionStatusDisabled, TransparentDataEncryptionStatusEnabled} +} + +// UnitDefinitionType enumerates the values for unit definition type. +type UnitDefinitionType string + +const ( + // UnitDefinitionTypeBytes ... + UnitDefinitionTypeBytes UnitDefinitionType = "Bytes" + // UnitDefinitionTypeBytesPerSecond ... + UnitDefinitionTypeBytesPerSecond UnitDefinitionType = "BytesPerSecond" + // UnitDefinitionTypeCount ... + UnitDefinitionTypeCount UnitDefinitionType = "Count" + // UnitDefinitionTypeCountPerSecond ... + UnitDefinitionTypeCountPerSecond UnitDefinitionType = "CountPerSecond" + // UnitDefinitionTypePercent ... + UnitDefinitionTypePercent UnitDefinitionType = "Percent" + // UnitDefinitionTypeSeconds ... + UnitDefinitionTypeSeconds UnitDefinitionType = "Seconds" +) + +// PossibleUnitDefinitionTypeValues returns an array of possible values for the UnitDefinitionType const type. +func PossibleUnitDefinitionTypeValues() []UnitDefinitionType { + return []UnitDefinitionType{UnitDefinitionTypeBytes, UnitDefinitionTypeBytesPerSecond, UnitDefinitionTypeCount, UnitDefinitionTypeCountPerSecond, UnitDefinitionTypePercent, UnitDefinitionTypeSeconds} +} + +// UnitType enumerates the values for unit type. +type UnitType string + +const ( + // UnitTypeBytes ... + UnitTypeBytes UnitType = "bytes" + // UnitTypeBytesPerSecond ... + UnitTypeBytesPerSecond UnitType = "bytesPerSecond" + // UnitTypeCount ... + UnitTypeCount UnitType = "count" + // UnitTypeCountPerSecond ... + UnitTypeCountPerSecond UnitType = "countPerSecond" + // UnitTypePercent ... + UnitTypePercent UnitType = "percent" + // UnitTypeSeconds ... + UnitTypeSeconds UnitType = "seconds" +) + +// PossibleUnitTypeValues returns an array of possible values for the UnitType const type. +func PossibleUnitTypeValues() []UnitType { + return []UnitType{UnitTypeBytes, UnitTypeBytesPerSecond, UnitTypeCount, UnitTypeCountPerSecond, UnitTypePercent, UnitTypeSeconds} +} + +// VirtualNetworkRuleState enumerates the values for virtual network rule state. +type VirtualNetworkRuleState string + +const ( + // VirtualNetworkRuleStateDeleting ... + VirtualNetworkRuleStateDeleting VirtualNetworkRuleState = "Deleting" + // VirtualNetworkRuleStateInitializing ... + VirtualNetworkRuleStateInitializing VirtualNetworkRuleState = "Initializing" + // VirtualNetworkRuleStateInProgress ... + VirtualNetworkRuleStateInProgress VirtualNetworkRuleState = "InProgress" + // VirtualNetworkRuleStateReady ... + VirtualNetworkRuleStateReady VirtualNetworkRuleState = "Ready" + // VirtualNetworkRuleStateUnknown ... + VirtualNetworkRuleStateUnknown VirtualNetworkRuleState = "Unknown" +) + +// PossibleVirtualNetworkRuleStateValues returns an array of possible values for the VirtualNetworkRuleState const type. +func PossibleVirtualNetworkRuleStateValues() []VirtualNetworkRuleState { + return []VirtualNetworkRuleState{VirtualNetworkRuleStateDeleting, VirtualNetworkRuleStateInitializing, VirtualNetworkRuleStateInProgress, VirtualNetworkRuleStateReady, VirtualNetworkRuleStateUnknown} +} + +// VulnerabilityAssessmentPolicyBaselineName enumerates the values for vulnerability assessment policy baseline +// name. +type VulnerabilityAssessmentPolicyBaselineName string + +const ( + // VulnerabilityAssessmentPolicyBaselineNameDefault ... + VulnerabilityAssessmentPolicyBaselineNameDefault VulnerabilityAssessmentPolicyBaselineName = "default" + // VulnerabilityAssessmentPolicyBaselineNameMaster ... + VulnerabilityAssessmentPolicyBaselineNameMaster VulnerabilityAssessmentPolicyBaselineName = "master" +) + +// PossibleVulnerabilityAssessmentPolicyBaselineNameValues returns an array of possible values for the VulnerabilityAssessmentPolicyBaselineName const type. +func PossibleVulnerabilityAssessmentPolicyBaselineNameValues() []VulnerabilityAssessmentPolicyBaselineName { + return []VulnerabilityAssessmentPolicyBaselineName{VulnerabilityAssessmentPolicyBaselineNameDefault, VulnerabilityAssessmentPolicyBaselineNameMaster} +} + +// VulnerabilityAssessmentScanState enumerates the values for vulnerability assessment scan state. +type VulnerabilityAssessmentScanState string + +const ( + // VulnerabilityAssessmentScanStateFailed ... + VulnerabilityAssessmentScanStateFailed VulnerabilityAssessmentScanState = "Failed" + // VulnerabilityAssessmentScanStateFailedToRun ... + VulnerabilityAssessmentScanStateFailedToRun VulnerabilityAssessmentScanState = "FailedToRun" + // VulnerabilityAssessmentScanStateInProgress ... + VulnerabilityAssessmentScanStateInProgress VulnerabilityAssessmentScanState = "InProgress" + // VulnerabilityAssessmentScanStatePassed ... + VulnerabilityAssessmentScanStatePassed VulnerabilityAssessmentScanState = "Passed" +) + +// PossibleVulnerabilityAssessmentScanStateValues returns an array of possible values for the VulnerabilityAssessmentScanState const type. +func PossibleVulnerabilityAssessmentScanStateValues() []VulnerabilityAssessmentScanState { + return []VulnerabilityAssessmentScanState{VulnerabilityAssessmentScanStateFailed, VulnerabilityAssessmentScanStateFailedToRun, VulnerabilityAssessmentScanStateInProgress, VulnerabilityAssessmentScanStatePassed} +} + +// VulnerabilityAssessmentScanTriggerType enumerates the values for vulnerability assessment scan trigger type. +type VulnerabilityAssessmentScanTriggerType string + +const ( + // VulnerabilityAssessmentScanTriggerTypeOnDemand ... + VulnerabilityAssessmentScanTriggerTypeOnDemand VulnerabilityAssessmentScanTriggerType = "OnDemand" + // VulnerabilityAssessmentScanTriggerTypeRecurring ... + VulnerabilityAssessmentScanTriggerTypeRecurring VulnerabilityAssessmentScanTriggerType = "Recurring" +) + +// PossibleVulnerabilityAssessmentScanTriggerTypeValues returns an array of possible values for the VulnerabilityAssessmentScanTriggerType const type. +func PossibleVulnerabilityAssessmentScanTriggerTypeValues() []VulnerabilityAssessmentScanTriggerType { + return []VulnerabilityAssessmentScanTriggerType{VulnerabilityAssessmentScanTriggerTypeOnDemand, VulnerabilityAssessmentScanTriggerTypeRecurring} +} diff --git a/services/preview/sql/mgmt/v3.0/sql/extendeddatabaseblobauditingpolicies.go b/services/preview/sql/mgmt/v3.0/sql/extendeddatabaseblobauditingpolicies.go new file mode 100644 index 000000000000..690f3cf08d06 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/extendeddatabaseblobauditingpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ExtendedDatabaseBlobAuditingPoliciesClient 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 ExtendedDatabaseBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewExtendedDatabaseBlobAuditingPoliciesClient creates an instance of the ExtendedDatabaseBlobAuditingPoliciesClient +// client. +func NewExtendedDatabaseBlobAuditingPoliciesClient(subscriptionID string) ExtendedDatabaseBlobAuditingPoliciesClient { + return NewExtendedDatabaseBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExtendedDatabaseBlobAuditingPoliciesClientWithBaseURI creates an instance of the +// ExtendedDatabaseBlobAuditingPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewExtendedDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ExtendedDatabaseBlobAuditingPoliciesClient { + return ExtendedDatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an extended database's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the extended database blob auditing policy. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExtendedDatabaseBlobAuditingPolicy) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "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.ExtendedDatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExtendedDatabaseBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}", 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 ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an extended database's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "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.ExtendedDatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "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}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}", 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 ExtendedDatabaseBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists extended auditing settings of a database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ExtendedDatabaseBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.edbaplr.Response.Response != nil { + sc = result.edbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.edbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.edbaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.edbaplr.hasNextLink() && result.edbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer(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 = "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}/databases/{databaseName}/extendedAuditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ExtendedDatabaseBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ExtendedDatabaseBlobAuditingPolicyListResult) (result ExtendedDatabaseBlobAuditingPolicyListResult, err error) { + req, err := lastResults.extendedDatabaseBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ExtendedDatabaseBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/extendedserverblobauditingpolicies.go b/services/preview/sql/mgmt/v3.0/sql/extendedserverblobauditingpolicies.go new file mode 100644 index 000000000000..a906dae47a88 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/extendedserverblobauditingpolicies.go @@ -0,0 +1,316 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ExtendedServerBlobAuditingPoliciesClient 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 ExtendedServerBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewExtendedServerBlobAuditingPoliciesClient creates an instance of the ExtendedServerBlobAuditingPoliciesClient +// client. +func NewExtendedServerBlobAuditingPoliciesClient(subscriptionID string) ExtendedServerBlobAuditingPoliciesClient { + return NewExtendedServerBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExtendedServerBlobAuditingPoliciesClientWithBaseURI creates an instance of the +// ExtendedServerBlobAuditingPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewExtendedServerBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ExtendedServerBlobAuditingPoliciesClient { + return ExtendedServerBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an extended server's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - properties of extended blob auditing policy +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ExtendedServerBlobAuditingPolicy) (result ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ExtendedServerBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}", 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 ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ExtendedServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an extended server's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ExtendedServerBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ExtendedServerBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "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.ExtendedServerBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExtendedServerBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "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}/extendedAuditingSettings/{blobAuditingPolicyName}", 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 ExtendedServerBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExtendedServerBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result ExtendedServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists extended auditing settings of a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ExtendedServerBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.esbaplr.Response.Response != nil { + sc = result.esbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.esbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.esbaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.esbaplr.hasNextLink() && result.esbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ExtendedServerBlobAuditingPoliciesClient) 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}/extendedAuditingSettings", 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 ExtendedServerBlobAuditingPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerResponder(resp *http.Response) (result ExtendedServerBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + 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 ExtendedServerBlobAuditingPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ExtendedServerBlobAuditingPolicyListResult) (result ExtendedServerBlobAuditingPolicyListResult, err error) { + req, err := lastResults.extendedServerBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "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.ExtendedServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ExtendedServerBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/failovergroups.go b/services/preview/sql/mgmt/v3.0/sql/failovergroups.go new file mode 100644 index 000000000000..bab986e12e9e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/failovergroups.go @@ -0,0 +1,658 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FailoverGroupsClient 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 FailoverGroupsClient struct { + BaseClient +} + +// NewFailoverGroupsClient creates an instance of the FailoverGroupsClient client. +func NewFailoverGroupsClient(subscriptionID string) FailoverGroupsClient { + return NewFailoverGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFailoverGroupsClientWithBaseURI creates an instance of the FailoverGroupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) FailoverGroupsClient { + return FailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client FailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (result FailoverGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FailoverGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.FailoverGroupProperties.ReadWriteEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FailoverGroupProperties.PartnerServers", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.FailoverGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FailoverGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) CreateOrUpdateSender(req *http.Request) (future FailoverGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FailoverGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) DeleteSender(req *http.Request) (future FailoverGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary server to this server. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client FailoverGroupsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) FailoverSender(req *http.Request) (future FailoverGroupsFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) FailoverResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ForceFailoverAllowDataLoss fails over from the current primary server to this server. This operation might result in +// data loss. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ForceFailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ForceFailoverAllowDataLossPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.ForceFailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ForceFailoverAllowDataLoss", result.Response(), "Failure sending request") + return + } + + return +} + +// ForceFailoverAllowDataLossPreparer prepares the ForceFailoverAllowDataLoss request. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ForceFailoverAllowDataLossSender sends the ForceFailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossSender(req *http.Request) (future FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ForceFailoverAllowDataLossResponder handles the response to the ForceFailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "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.FailoverGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FailoverGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) GetResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the failover groups in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +func (client FailoverGroupsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ListByServer") + defer func() { + sc := -1 + if result.fglr.Response.Response != nil { + sc = result.fglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.fglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.fglr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.fglr.hasNextLink() && result.fglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FailoverGroupsClient) 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 = "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}/failoverGroups", 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 FailoverGroupsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ListByServerResponder(resp *http.Response) (result FailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + 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 FailoverGroupsClient) listByServerNextResults(ctx context.Context, lastResults FailoverGroupListResult) (result FailoverGroupListResult, err error) { + req, err := lastResults.failoverGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "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.FailoverGroupsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FailoverGroupsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a failover group. +// Parameters: +// resourceGroupName - 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 - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client FailoverGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (result FailoverGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client FailoverGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", 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 FailoverGroupsClient) UpdateSender(req *http.Request) (future FailoverGroupsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) UpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/firewallrules.go b/services/preview/sql/mgmt/v3.0/sql/firewallrules.go new file mode 100644 index 000000000000..3e79a6b3933c --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/firewallrules.go @@ -0,0 +1,361 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FirewallRulesClient 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 FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "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.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "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.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of firewall rules. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) 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 = "2014-04-01" + 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}/firewallRules", 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 FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/geobackuppolicies.go b/services/preview/sql/mgmt/v3.0/sql/geobackuppolicies.go new file mode 100644 index 000000000000..605603cc5f04 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/geobackuppolicies.go @@ -0,0 +1,285 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GeoBackupPoliciesClient 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 GeoBackupPoliciesClient struct { + BaseClient +} + +// NewGeoBackupPoliciesClient creates an instance of the GeoBackupPoliciesClient client. +func NewGeoBackupPoliciesClient(subscriptionID string) GeoBackupPoliciesClient { + return NewGeoBackupPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGeoBackupPoliciesClientWithBaseURI creates an instance of the GeoBackupPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewGeoBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) GeoBackupPoliciesClient { + return GeoBackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database geo backup policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating the geo backup policy. +func (client GeoBackupPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters GeoBackupPolicy) (result GeoBackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.GeoBackupPolicyProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.GeoBackupPoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "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.GeoBackupPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GeoBackupPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters GeoBackupPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "geoBackupPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", 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 GeoBackupPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a geo backup policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client GeoBackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "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.GeoBackupPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GeoBackupPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "geoBackupPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/geoBackupPolicies/{geoBackupPolicyName}", 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 GeoBackupPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) GetResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a list of geo backup policies. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client GeoBackupPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicyListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client GeoBackupPoliciesClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/geoBackupPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GeoBackupPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result GeoBackupPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/importexport.go b/services/preview/sql/mgmt/v3.0/sql/importexport.go new file mode 100644 index 000000000000..ba2dbfa8bead --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/importexport.go @@ -0,0 +1,128 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ImportExportClient 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 ImportExportClient struct { + BaseClient +} + +// NewImportExportClient creates an instance of the ImportExportClient client. +func NewImportExportClient(subscriptionID string) ImportExportClient { + return NewImportExportClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewImportExportClientWithBaseURI creates an instance of the ImportExportClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewImportExportClientWithBaseURI(baseURI string, subscriptionID string) ImportExportClient { + return ImportExportClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Import imports a bacpac into a new database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the database import request parameters. +func (client ImportExportClient) Import(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ImportExistingDatabaseDefinition) (result ImportExportImportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportClient.Import") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ImportExportClient", "Import", err.Error()) + } + + req, err := client.ImportPreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ImportExportClient", "Import", nil, "Failure preparing request") + return + } + + result, err = client.ImportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ImportExportClient", "Import", result.Response(), "Failure sending request") + return + } + + return +} + +// ImportPreparer prepares the Import request. +func (client ImportExportClient) ImportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ImportExistingDatabaseDefinition) (*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 = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImportSender sends the Import request. The method will close the +// http.Response Body if it receives an error. +func (client ImportExportClient) ImportSender(req *http.Request) (future ImportExportImportFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ImportResponder handles the response to the Import request. The method always +// closes the http.Response Body. +func (client ImportExportClient) ImportResponder(resp *http.Response) (result ImportExportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/instancefailovergroups.go b/services/preview/sql/mgmt/v3.0/sql/instancefailovergroups.go new file mode 100644 index 000000000000..fc2759bfaa00 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/instancefailovergroups.go @@ -0,0 +1,574 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InstanceFailoverGroupsClient 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 InstanceFailoverGroupsClient struct { + BaseClient +} + +// NewInstanceFailoverGroupsClient creates an instance of the InstanceFailoverGroupsClient client. +func NewInstanceFailoverGroupsClient(subscriptionID string) InstanceFailoverGroupsClient { + return NewInstanceFailoverGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInstanceFailoverGroupsClientWithBaseURI creates an instance of the InstanceFailoverGroupsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return InstanceFailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client InstanceFailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (result InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.InstanceFailoverGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstanceFailoverGroupProperties.PartnerRegions", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstanceFailoverGroupProperties.ManagedInstancePairs", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.InstanceFailoverGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, locationName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client InstanceFailoverGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", 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 InstanceFailoverGroupsClient) CreateOrUpdateSender(req *http.Request) (future InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client InstanceFailoverGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", 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 InstanceFailoverGroupsClient) DeleteSender(req *http.Request) (future InstanceFailoverGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary managed instance to this managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client InstanceFailoverGroupsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) FailoverSender(req *http.Request) (future InstanceFailoverGroupsFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) FailoverResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ForceFailoverAllowDataLoss fails over from the current primary managed instance to this managed instance. This +// operation might result in data loss. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ForceFailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ForceFailoverAllowDataLossPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.ForceFailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ForceFailoverAllowDataLoss", result.Response(), "Failure sending request") + return + } + + return +} + +// ForceFailoverAllowDataLossPreparer prepares the ForceFailoverAllowDataLoss request. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ForceFailoverAllowDataLossSender sends the ForceFailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossSender(req *http.Request) (future InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ForceFailoverAllowDataLossResponder handles the response to the ForceFailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "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.InstanceFailoverGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client InstanceFailoverGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", 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 InstanceFailoverGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) GetResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists the failover groups in a location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +func (client InstanceFailoverGroupsClient) ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result InstanceFailoverGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.ifglr.Response.Response != nil { + sc = result.ifglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, resourceGroupName, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.ifglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.ifglr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.ifglr.hasNextLink() && result.ifglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client InstanceFailoverGroupsClient) ListByLocationPreparer(ctx context.Context, resourceGroupName string, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/locations/{locationName}/instanceFailoverGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) ListByLocationResponder(resp *http.Response) (result InstanceFailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client InstanceFailoverGroupsClient) listByLocationNextResults(ctx context.Context, lastResults InstanceFailoverGroupListResult) (result InstanceFailoverGroupListResult, err error) { + req, err := lastResults.instanceFailoverGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstanceFailoverGroupsClient) ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result InstanceFailoverGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/instancepools.go b/services/preview/sql/mgmt/v3.0/sql/instancepools.go new file mode 100644 index 000000000000..6fe338f25f40 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/instancepools.go @@ -0,0 +1,597 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InstancePoolsClient 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 InstancePoolsClient struct { + BaseClient +} + +// NewInstancePoolsClient creates an instance of the InstancePoolsClient client. +func NewInstancePoolsClient(subscriptionID string) InstancePoolsClient { + return NewInstancePoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInstancePoolsClientWithBaseURI creates an instance of the InstancePoolsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewInstancePoolsClientWithBaseURI(baseURI string, subscriptionID string) InstancePoolsClient { + return InstancePoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be created or updated. +// parameters - the requested instance pool resource state. +func (client InstancePoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePool) (result InstancePoolsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.InstancePoolProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.InstancePoolProperties.SubnetID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstancePoolProperties.VCores", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.InstancePoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, instancePoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client InstancePoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", 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 InstancePoolsClient) CreateOrUpdateSender(req *http.Request) (future InstancePoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) CreateOrUpdateResponder(resp *http.Response) (result InstancePool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an instance pool +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be deleted +func (client InstancePoolsClient) Delete(ctx context.Context, resourceGroupName string, instancePoolName string) (result InstancePoolsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, instancePoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client InstancePoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, instancePoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/instancePools/{instancePoolName}", 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 InstancePoolsClient) DeleteSender(req *http.Request) (future InstancePoolsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be retrieved. +func (client InstancePoolsClient) Get(ctx context.Context, resourceGroupName string, instancePoolName string) (result InstancePool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, instancePoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "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.InstancePoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client InstancePoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, instancePoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/instancePools/{instancePoolName}", 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 InstancePoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) GetResponder(resp *http.Response) (result InstancePool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all instance pools in the subscription. +func (client InstancePoolsClient) List(ctx context.Context) (result InstancePoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.List") + defer func() { + sc := -1 + if result.iplr.Response.Response != nil { + sc = result.iplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.iplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "List", resp, "Failure sending request") + return + } + + result.iplr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "List", resp, "Failure responding to request") + return + } + if result.iplr.hasNextLink() && result.iplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client InstancePoolsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) ListResponder(resp *http.Response) (result InstancePoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client InstancePoolsClient) listNextResults(ctx context.Context, lastResults InstancePoolListResult) (result InstancePoolListResult, err error) { + req, err := lastResults.instancePoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstancePoolsClient) ListComplete(ctx context.Context) (result InstancePoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of instance pools in the resource group +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client InstancePoolsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result InstancePoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.iplr.Response.Response != nil { + sc = result.iplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.iplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.iplr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.iplr.hasNextLink() && result.iplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client InstancePoolsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/instancePools", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) ListByResourceGroupResponder(resp *http.Response) (result InstancePoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client InstancePoolsClient) listByResourceGroupNextResults(ctx context.Context, lastResults InstancePoolListResult) (result InstancePoolListResult, err error) { + req, err := lastResults.instancePoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstancePoolsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result InstancePoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be updated. +// parameters - the requested instance pool resource state. +func (client InstancePoolsClient) Update(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePoolUpdate) (result InstancePoolsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, instancePoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client InstancePoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePoolUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", 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 InstancePoolsClient) UpdateSender(req *http.Request) (future InstancePoolsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) UpdateResponder(resp *http.Response) (result InstancePool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobagents.go b/services/preview/sql/mgmt/v3.0/sql/jobagents.go new file mode 100644 index 000000000000..ac60892a9387 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobagents.go @@ -0,0 +1,492 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobAgentsClientWithBaseURI(baseURI string, subscriptionID string) JobAgentsClient { + return JobAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job agent. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent to be created or updated. +// parameters - 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 tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {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.NewError("sql.JobAgentsClient", "CreateOrUpdate", err.Error()) + } + + 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.AsContentType("application/json; charset=utf-8"), + 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) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + 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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job agent. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + 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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client JobAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result JobAgentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.jalr.Response.Response != nil { + sc = result.jalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jalr.hasNextLink() && result.jalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobAgentListResult) (result JobAgentListResult, err error) { + req, err := lastResults.jobAgentListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a job agent. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent to be updated. +// parameters - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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.AsContentType("application/json; charset=utf-8"), + 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) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobcredentials.go b/services/preview/sql/mgmt/v3.0/sql/jobcredentials.go new file mode 100644 index 000000000000..883242aa6845 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobcredentials.go @@ -0,0 +1,409 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobCredentialsClientWithBaseURI(baseURI string, subscriptionID string) JobCredentialsClient { + return JobCredentialsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job credential. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// credentialName - the name of the credential. +// parameters - 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 tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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.NewError("sql.JobCredentialsClient", "CreateOrUpdate", err.Error()) + } + + 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 + } + + 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.AsContentType("application/json; charset=utf-8"), + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job credential. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// credentialName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a jobs credential. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// credentialName - the name of the credential. +func (client JobCredentialsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result JobCredential, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets a list of jobs credentials. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +func (client JobCredentialsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobCredentialListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.ListByAgent") + defer func() { + sc := -1 + if result.jclr.Response.Response != nil { + sc = result.jclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jclr.hasNextLink() && result.jclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobCredentialListResult) (result JobCredentialListResult, err error) { + req, err := lastResults.jobCredentialListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobexecutions.go b/services/preview/sql/mgmt/v3.0/sql/jobexecutions.go new file mode 100644 index 000000000000..c4bb7d6af6c9 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobexecutions.go @@ -0,0 +1,670 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/date" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobExecutionsClient { + return JobExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel requests cancellation of a job execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobExecutionID - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create starts an elastic job execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a job execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + 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, + 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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobExecutionID - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent lists all executions in a job agent. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobExecutionsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByAgent") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + 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 + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobExecutionsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*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 createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + 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, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} + +// ListByJob lists a job's executions. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobExecutionsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByJob") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + 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 + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobExecutionsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*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 createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + 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, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByJob") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobs.go b/services/preview/sql/mgmt/v3.0/sql/jobs.go new file mode 100644 index 000000000000..457236877e18 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobs.go @@ -0,0 +1,399 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "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 using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient { + return JobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// parameters - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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.AsContentType("application/json; charset=utf-8"), + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets a list of jobs. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +func (client JobsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.ListByAgent") + defer func() { + sc := -1 + if result.jlr.Response.Response != nil { + sc = result.jlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jlr.hasNextLink() && result.jlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobListResult) (result JobListResult, err error) { + req, err := lastResults.jobListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobstepexecutions.go b/services/preview/sql/mgmt/v3.0/sql/jobstepexecutions.go new file mode 100644 index 000000000000..d01dc77a65ee --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobstepexecutions.go @@ -0,0 +1,274 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/date" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// JobStepExecutionsClient 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 JobStepExecutionsClient struct { + BaseClient +} + +// NewJobStepExecutionsClient creates an instance of the JobStepExecutionsClient client. +func NewJobStepExecutionsClient(subscriptionID string) JobStepExecutionsClient { + return NewJobStepExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobStepExecutionsClientWithBaseURI creates an instance of the JobStepExecutionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewJobStepExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobStepExecutionsClient { + return JobStepExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a step execution of a job execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the unique id of the job execution +// stepName - the name of the step. +func (client JobStepExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (result JobExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "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.JobStepExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStepExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (*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), + "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}/executions/{jobExecutionId}/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 JobStepExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStepExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJobExecution lists the step executions of a job execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the id of the job execution +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobStepExecutionsClient) ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobExecutionNextResults + req, err := client.ListByJobExecutionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobExecutionPreparer prepares the ListByJobExecution request. +func (client JobStepExecutionsClient) ListByJobExecutionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*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, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + 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}/steps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobExecutionSender sends the ListByJobExecution request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepExecutionsClient) ListByJobExecutionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobExecutionResponder handles the response to the ListByJobExecution request. The method always +// closes the http.Response Body. +func (client JobStepExecutionsClient) ListByJobExecutionResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobExecutionNextResults retrieves the next set of results, if any. +func (client JobStepExecutionsClient) listByJobExecutionNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobExecutionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStepExecutionsClient) ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJobExecution(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobsteps.go b/services/preview/sql/mgmt/v3.0/sql/jobsteps.go new file mode 100644 index 000000000000..3011a7a25d02 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobsteps.go @@ -0,0 +1,635 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// stepName - the name of the job step. +// parameters - 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 tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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.ServerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.DatabaseName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.TableName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.Credential", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("sql.JobStepsClient", "CreateOrUpdate", err.Error()) + } + + 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 + } + + 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.AsContentType("application/json; charset=utf-8"), + 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 client.Send(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, + 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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// stepName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job step in a job's current version. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// stepName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + 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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobVersion - the version of the job to get. +// stepName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.GetByVersion") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + 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. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByJob") + defer func() { + sc := -1 + if result.jslr.Response.Response != nil { + sc = result.jslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jslr.hasNextLink() && result.jslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobStepListResult) (result JobStepListResult, err error) { + req, err := lastResults.jobStepListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByJob") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName) + return +} + +// ListByVersion gets all job steps in the specified job version. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobVersion - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByVersion") + defer func() { + sc := -1 + if result.jslr.Response.Response != nil { + sc = result.jslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jslr.hasNextLink() && result.jslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobStepListResult) (result JobStepListResult, err error) { + req, err := lastResults.jobStepListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByVersion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByVersion(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobtargetexecutions.go b/services/preview/sql/mgmt/v3.0/sql/jobtargetexecutions.go new file mode 100644 index 000000000000..2e72ab31c1b7 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobtargetexecutions.go @@ -0,0 +1,431 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/date" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// JobTargetExecutionsClient 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 JobTargetExecutionsClient struct { + BaseClient +} + +// NewJobTargetExecutionsClient creates an instance of the JobTargetExecutionsClient client. +func NewJobTargetExecutionsClient(subscriptionID string) JobTargetExecutionsClient { + return NewJobTargetExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobTargetExecutionsClientWithBaseURI creates an instance of the JobTargetExecutionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewJobTargetExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobTargetExecutionsClient { + return JobTargetExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a target execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the unique id of the job execution +// stepName - the name of the step. +// targetID - the target id. +func (client JobTargetExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, targetID uuid.UUID) (result JobExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName, targetID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "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.JobTargetExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobTargetExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, targetID 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), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetId": autorest.Encode("path", targetID), + } + + 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}/steps/{stepName}/targets/{targetId}", 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 JobTargetExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobTargetExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJobExecution lists target executions for all steps of a job execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the id of the job execution +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobTargetExecutionsClient) ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobExecutionNextResults + req, err := client.ListByJobExecutionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByJobExecution", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByJobExecution", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByJobExecution", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobExecutionPreparer prepares the ListByJobExecution request. +func (client JobTargetExecutionsClient) ListByJobExecutionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*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, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + 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}/targets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobExecutionSender sends the ListByJobExecution request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetExecutionsClient) ListByJobExecutionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobExecutionResponder handles the response to the ListByJobExecution request. The method always +// closes the http.Response Body. +func (client JobTargetExecutionsClient) ListByJobExecutionResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobExecutionNextResults retrieves the next set of results, if any. +func (client JobTargetExecutionsClient) listByJobExecutionNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByJobExecutionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByJobExecutionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByJobExecutionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobExecutionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobTargetExecutionsClient) ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJobExecution(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} + +// ListByStep lists the target executions of a job step execution. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the id of the job execution +// stepName - the name of the step. +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobTargetExecutionsClient) ListByStep(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByStep") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByStepNextResults + req, err := client.ListByStepPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByStep", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStepSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByStep", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByStepResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByStep", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByStepPreparer prepares the ListByStep request. +func (client JobTargetExecutionsClient) ListByStepPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*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), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + 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}/steps/{stepName}/targets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByStepSender sends the ListByStep request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetExecutionsClient) ListByStepSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByStepResponder handles the response to the ListByStep request. The method always +// closes the http.Response Body. +func (client JobTargetExecutionsClient) ListByStepResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByStepNextResults retrieves the next set of results, if any. +func (client JobTargetExecutionsClient) listByStepNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByStepNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByStepSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByStepNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByStepResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByStepNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByStepComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobTargetExecutionsClient) ListByStepComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByStep") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByStep(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobtargetgroups.go b/services/preview/sql/mgmt/v3.0/sql/jobtargetgroups.go new file mode 100644 index 000000000000..74b54d3e1226 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobtargetgroups.go @@ -0,0 +1,407 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobTargetGroupsClientWithBaseURI(baseURI string, subscriptionID string) JobTargetGroupsClient { + return JobTargetGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a target group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// targetGroupName - the name of the target group. +// parameters - 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 tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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.NewError("sql.JobTargetGroupsClient", "CreateOrUpdate", err.Error()) + } + + 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 + } + + 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.AsContentType("application/json; charset=utf-8"), + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a target group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// targetGroupName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a target group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// targetGroupName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets all target groups in an agent. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +func (client JobTargetGroupsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobTargetGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.ListByAgent") + defer func() { + sc := -1 + if result.jtglr.Response.Response != nil { + sc = result.jtglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jtglr.hasNextLink() && result.jtglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobTargetGroupListResult) (result JobTargetGroupListResult, err error) { + req, err := lastResults.jobTargetGroupListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/jobversions.go b/services/preview/sql/mgmt/v3.0/sql/jobversions.go new file mode 100644 index 000000000000..8911c3fa38ca --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/jobversions.go @@ -0,0 +1,239 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "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 using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobVersionsClientWithBaseURI(baseURI string, subscriptionID string) JobVersionsClient { + return JobVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a job version. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobVersion - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob gets all versions of a job. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionsClient.ListByJob") + defer func() { + sc := -1 + if result.jvlr.Response.Response != nil { + sc = result.jvlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + if result.jvlr.hasNextLink() && result.jvlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 client.Send(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, + 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(ctx context.Context, lastResults JobVersionListResult) (result JobVersionListResult, err error) { + req, err := lastResults.jobVersionListResultPreparer(ctx) + 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) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionsClient.ListByJob") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/longtermretentionbackups.go b/services/preview/sql/mgmt/v3.0/sql/longtermretentionbackups.go new file mode 100644 index 000000000000..c2b40d332dd1 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/longtermretentionbackups.go @@ -0,0 +1,1129 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// LongTermRetentionBackupsClient 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 LongTermRetentionBackupsClient struct { + BaseClient +} + +// NewLongTermRetentionBackupsClient creates an instance of the LongTermRetentionBackupsClient client. +func NewLongTermRetentionBackupsClient(subscriptionID string) LongTermRetentionBackupsClient { + return NewLongTermRetentionBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLongTermRetentionBackupsClientWithBaseURI creates an instance of the LongTermRetentionBackupsClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewLongTermRetentionBackupsClientWithBaseURI(baseURI string, subscriptionID string) LongTermRetentionBackupsClient { + return LongTermRetentionBackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a long term retention backup. +// Parameters: +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LongTermRetentionBackupsClient) DeletePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "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}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", 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 LongTermRetentionBackupsClient) DeleteSender(req *http.Request) (future LongTermRetentionBackupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByResourceGroup deletes a long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.DeleteByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "DeleteByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.DeleteByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "DeleteByResourceGroup", result.Response(), "Failure sending request") + return + } + + return +} + +// DeleteByResourceGroupPreparer prepares the DeleteByResourceGroup request. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByResourceGroupSender sends the DeleteByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroupSender(req *http.Request) (future LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteByResourceGroupResponder handles the response to the DeleteByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroupResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a long term retention backup. +// Parameters: +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "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.LongTermRetentionBackupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LongTermRetentionBackupsClient) GetPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "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}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", 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 LongTermRetentionBackupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) GetResponder(resp *http.Response) (result LongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByResourceGroup gets a long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.GetByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "GetByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "GetByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "GetByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// GetByResourceGroupPreparer prepares the GetByResourceGroup request. +func (client LongTermRetentionBackupsClient) GetByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByResourceGroupSender sends the GetByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) GetByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByResourceGroupResponder handles the response to the GetByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) GetByResourceGroupResponder(resp *http.Response) (result LongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists all long term retention backups for a database. +// Parameters: +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LongTermRetentionBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByDatabaseResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByDatabaseNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByLocation lists the long term retention backups for a given location. +// Parameters: +// locationName - the location of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client LongTermRetentionBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByLocationResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByLocationNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupDatabase lists all long term retention backups for a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupDatabaseNextResults + req, err := client.ListByResourceGroupDatabasePreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupDatabase", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupDatabase", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupDatabasePreparer prepares the ListByResourceGroupDatabase request. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupDatabaseSender sends the ListByResourceGroupDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupDatabaseResponder handles the response to the ListByResourceGroupDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByResourceGroupDatabaseNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupDatabase(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupLocation lists the long term retention backups for a given location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupLocationNextResults + req, err := client.ListByResourceGroupLocationPreparer(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupLocation", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupLocation", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupLocationPreparer prepares the ListByResourceGroupLocation request. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupLocationSender sends the ListByResourceGroupLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupLocationResponder handles the response to the ListByResourceGroupLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByResourceGroupLocationNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupLocation(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupServer lists the long term retention backups for a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupServer") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupServerNextResults + req, err := client.ListByResourceGroupServerPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupServerSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupServer", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByResourceGroupServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupServer", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupServerPreparer prepares the ListByResourceGroupServer request. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupServerSender sends the ListByResourceGroupServer request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupServerResponder handles the response to the ListByResourceGroupServer request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupServerNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByResourceGroupServerNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupServer(ctx, resourceGroupName, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByServer lists the long term retention backups for a given server. +// Parameters: +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByServer") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client LongTermRetentionBackupsClient) ListByServerPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", 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 LongTermRetentionBackupsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByServerResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + 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 LongTermRetentionBackupsClient) listByServerNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "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.LongTermRetentionBackupsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/longtermretentionmanagedinstancebackups.go b/services/preview/sql/mgmt/v3.0/sql/longtermretentionmanagedinstancebackups.go new file mode 100644 index 000000000000..a0b0712c782d --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/longtermretentionmanagedinstancebackups.go @@ -0,0 +1,1130 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// LongTermRetentionManagedInstanceBackupsClient 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 LongTermRetentionManagedInstanceBackupsClient struct { + BaseClient +} + +// NewLongTermRetentionManagedInstanceBackupsClient creates an instance of the +// LongTermRetentionManagedInstanceBackupsClient client. +func NewLongTermRetentionManagedInstanceBackupsClient(subscriptionID string) LongTermRetentionManagedInstanceBackupsClient { + return NewLongTermRetentionManagedInstanceBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLongTermRetentionManagedInstanceBackupsClientWithBaseURI creates an instance of the +// LongTermRetentionManagedInstanceBackupsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLongTermRetentionManagedInstanceBackupsClientWithBaseURI(baseURI string, subscriptionID string) LongTermRetentionManagedInstanceBackupsClient { + return LongTermRetentionManagedInstanceBackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a long term retention backup. +// Parameters: +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) Delete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LongTermRetentionManagedInstanceBackupsClient) DeletePreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", 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 LongTermRetentionManagedInstanceBackupsClient) DeleteSender(req *http.Request) (future LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByResourceGroup deletes a long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.DeleteByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByResourceGroupPreparer(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "DeleteByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.DeleteByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "DeleteByResourceGroup", result.Response(), "Failure sending request") + return + } + + return +} + +// DeleteByResourceGroupPreparer prepares the DeleteByResourceGroup request. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByResourceGroupSender sends the DeleteByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroupSender(req *http.Request) (future LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteByResourceGroupResponder handles the response to the DeleteByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroupResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a long term retention backup for a managed database. +// Parameters: +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result ManagedInstanceLongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "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.LongTermRetentionManagedInstanceBackupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LongTermRetentionManagedInstanceBackupsClient) GetPreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", 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 LongTermRetentionManagedInstanceBackupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) GetResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByResourceGroup gets a long term retention backup for a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result ManagedInstanceLongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.GetByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByResourceGroupPreparer(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "GetByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "GetByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "GetByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// GetByResourceGroupPreparer prepares the GetByResourceGroup request. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByResourceGroupSender sends the GetByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByResourceGroupResponder handles the response to the GetByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists all long term retention backups for a managed database. +// Parameters: +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState1) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState1) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState1) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByInstance lists the long term retention backups for a given managed instance. +// Parameters: +// locationName - the location of the database +// managedInstanceName - the name of the managed instance. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState2) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByInstance") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstancePreparer(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState2) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState2) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByLocation lists the long term retention backups for managed databases in a given location. +// Parameters: +// locationName - the location of the database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState3) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState3) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByLocationNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState3) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupDatabase lists all long term retention backups for a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState4) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupDatabaseNextResults + req, err := client.ListByResourceGroupDatabasePreparer(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupDatabase", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupDatabase", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupDatabasePreparer prepares the ListByResourceGroupDatabase request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState4) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupDatabaseSender sends the ListByResourceGroupDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupDatabaseResponder handles the response to the ListByResourceGroupDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupDatabaseNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState4) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupDatabase(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupInstance lists the long term retention backups for a given managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState5) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupInstanceNextResults + req, err := client.ListByResourceGroupInstancePreparer(ctx, resourceGroupName, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupInstanceSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupInstance", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByResourceGroupInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupInstance", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupInstancePreparer prepares the ListByResourceGroupInstance request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstancePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState5) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupInstanceSender sends the ListByResourceGroupInstance request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupInstanceResponder handles the response to the ListByResourceGroupInstance request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupInstanceNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupInstanceNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState5) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupInstance(ctx, resourceGroupName, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupLocation lists the long term retention backups for managed databases in a given location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState6) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupLocationNextResults + req, err := client.ListByResourceGroupLocationPreparer(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupLocation", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupLocation", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupLocationPreparer prepares the ListByResourceGroupLocation request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState6) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupLocationSender sends the ListByResourceGroupLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupLocationResponder handles the response to the ListByResourceGroupLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupLocationNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState6) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupLocation(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedbackupshorttermretentionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/managedbackupshorttermretentionpolicies.go new file mode 100644 index 000000000000..91e75e1aa6c1 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedbackupshorttermretentionpolicies.go @@ -0,0 +1,408 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedBackupShortTermRetentionPoliciesClient 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 ManagedBackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewManagedBackupShortTermRetentionPoliciesClient creates an instance of the +// ManagedBackupShortTermRetentionPoliciesClient client. +func NewManagedBackupShortTermRetentionPoliciesClient(subscriptionID string) ManagedBackupShortTermRetentionPoliciesClient { + return NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// ManagedBackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedBackupShortTermRetentionPoliciesClient { + return ManagedBackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a managed database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedBackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedBackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "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.ManagedBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedBackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 ManagedBackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a managed database's short term retention policy list. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedBackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.mbstrplr.Response.Response != nil { + sc = result.mbstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.mbstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.mbstrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.mbstrplr.hasNextLink() && result.mbstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedBackupShortTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedBackupShortTermRetentionPolicyListResult) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.managedBackupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedBackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} + +// Update updates a managed database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client ManagedBackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedBackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedBackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", 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 ManagedBackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future ManagedBackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/manageddatabases.go b/services/preview/sql/mgmt/v3.0/sql/manageddatabases.go new file mode 100644 index 000000000000..cdb52af38d8a --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/manageddatabases.go @@ -0,0 +1,693 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabasesClient 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 ManagedDatabasesClient struct { + BaseClient +} + +// NewManagedDatabasesClient creates an instance of the ManagedDatabasesClient client. +func NewManagedDatabasesClient(subscriptionID string) ManagedDatabasesClient { + return NewManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabasesClientWithBaseURI creates an instance of the ManagedDatabasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabasesClient { + return ManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CompleteRestore completes the restore operation on a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the definition for completing the restore of this managed database. +func (client ManagedDatabasesClient) CompleteRestore(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters CompleteDatabaseRestoreDefinition) (result ManagedDatabasesCompleteRestoreFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.CompleteRestore") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LastBackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ManagedDatabasesClient", "CompleteRestore", err.Error()) + } + + req, err := client.CompleteRestorePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CompleteRestore", nil, "Failure preparing request") + return + } + + result, err = client.CompleteRestoreSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CompleteRestore", result.Response(), "Failure sending request") + return + } + + return +} + +// CompleteRestorePreparer prepares the CompleteRestore request. +func (client ManagedDatabasesClient) CompleteRestorePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters CompleteDatabaseRestoreDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CompleteRestoreSender sends the CompleteRestore request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) CompleteRestoreSender(req *http.Request) (future ManagedDatabasesCompleteRestoreFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CompleteRestoreResponder handles the response to the CompleteRestore request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) CompleteRestoreResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client ManagedDatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase) (result ManagedDatabasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", 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 ManagedDatabasesClient) CreateOrUpdateSender(req *http.Request) (future ManagedDatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabasesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/databases/{databaseName}", 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 ManagedDatabasesClient) DeleteSender(req *http.Request) (future ManagedDatabasesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "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.ManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/databases/{databaseName}", 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 ManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) GetResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.mdlr.Response.Response != nil { + sc = result.mdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mdlr.hasNextLink() && result.mdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result ManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedDatabaseListResult) (result ManagedDatabaseListResult, err error) { + req, err := lastResults.managedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// ListInaccessibleByInstance gets a list of inaccessible managed databases in a managed instance +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedDatabasesClient) ListInaccessibleByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListInaccessibleByInstance") + defer func() { + sc := -1 + if result.mdlr.Response.Response != nil { + sc = result.mdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listInaccessibleByInstanceNextResults + req, err := client.ListInaccessibleByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListInaccessibleByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListInaccessibleByInstanceSender(req) + if err != nil { + result.mdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListInaccessibleByInstance", resp, "Failure sending request") + return + } + + result.mdlr, err = client.ListInaccessibleByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListInaccessibleByInstance", resp, "Failure responding to request") + return + } + if result.mdlr.hasNextLink() && result.mdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListInaccessibleByInstancePreparer prepares the ListInaccessibleByInstance request. +func (client ManagedDatabasesClient) ListInaccessibleByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/inaccessibleManagedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInaccessibleByInstanceSender sends the ListInaccessibleByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) ListInaccessibleByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInaccessibleByInstanceResponder handles the response to the ListInaccessibleByInstance request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) ListInaccessibleByInstanceResponder(resp *http.Response) (result ManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInaccessibleByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedDatabasesClient) listInaccessibleByInstanceNextResults(ctx context.Context, lastResults ManagedDatabaseListResult) (result ManagedDatabaseListResult, err error) { + req, err := lastResults.managedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listInaccessibleByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInaccessibleByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listInaccessibleByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInaccessibleByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listInaccessibleByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInaccessibleByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabasesClient) ListInaccessibleByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListInaccessibleByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListInaccessibleByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Update updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client ManagedDatabasesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseUpdate) (result ManagedDatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedDatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", 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 ManagedDatabasesClient) UpdateSender(req *http.Request) (future ManagedDatabasesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) UpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/manageddatabasesecurityalertpolicies.go b/services/preview/sql/mgmt/v3.0/sql/manageddatabasesecurityalertpolicies.go new file mode 100644 index 000000000000..58b443e4fb93 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/manageddatabasesecurityalertpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedDatabaseSecurityAlertPoliciesClient 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 ManagedDatabaseSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewManagedDatabaseSecurityAlertPoliciesClient creates an instance of the ManagedDatabaseSecurityAlertPoliciesClient +// client. +func NewManagedDatabaseSecurityAlertPoliciesClient(subscriptionID string) ManagedDatabaseSecurityAlertPoliciesClient { + return NewManagedDatabaseSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseSecurityAlertPoliciesClientWithBaseURI creates an instance of the +// ManagedDatabaseSecurityAlertPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseSecurityAlertPoliciesClient { + return ManagedDatabaseSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policy is defined. +// parameters - the database security alert policy. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseSecurityAlertPolicy) (result ManagedDatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "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.ManagedDatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", 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 ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedDatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policy is defined. +func (client ManagedDatabaseSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "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.ManagedDatabaseSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "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/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", 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 ManagedDatabaseSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ManagedDatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of managed database's security alert policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policies are defined. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.mdsaplr.Response.Response != nil { + sc = result.mdsaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.mdsaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.mdsaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.mdsaplr.hasNextLink() && result.mdsaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ManagedDatabaseSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSecurityAlertPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedDatabaseSecurityAlertPolicyListResult) (result ManagedDatabaseSecurityAlertPolicyListResult, err error) { + req, err := lastResults.managedDatabaseSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/manageddatabasesensitivitylabels.go b/services/preview/sql/mgmt/v3.0/sql/manageddatabasesensitivitylabels.go new file mode 100644 index 000000000000..2a4000e00e5e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/manageddatabasesensitivitylabels.go @@ -0,0 +1,723 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedDatabaseSensitivityLabelsClient 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 ManagedDatabaseSensitivityLabelsClient struct { + BaseClient +} + +// NewManagedDatabaseSensitivityLabelsClient creates an instance of the ManagedDatabaseSensitivityLabelsClient client. +func NewManagedDatabaseSensitivityLabelsClient(subscriptionID string) ManagedDatabaseSensitivityLabelsClient { + return NewManagedDatabaseSensitivityLabelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseSensitivityLabelsClientWithBaseURI creates an instance of the +// ManagedDatabaseSensitivityLabelsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseSensitivityLabelsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseSensitivityLabelsClient { + return ManagedDatabaseSensitivityLabelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// parameters - the column sensitivity label resource. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "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.ManagedDatabaseSensitivityLabelsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", 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 ManagedDatabaseSensitivityLabelsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdateResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseSensitivityLabelsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseSensitivityLabelsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", 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 ManagedDatabaseSensitivityLabelsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DisableRecommendation disables sensitivity recommendations on a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.DisableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DisableRecommendationPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "DisableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.DisableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "DisableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.DisableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "DisableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// DisableRecommendationPreparer prepares the DisableRecommendation request. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendationPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisableRecommendationSender sends the DisableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DisableRecommendationResponder handles the response to the DisableRecommendation request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableRecommendation enables sensitivity recommendations on a given column (recommendations are enabled by default +// on all columns) +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.EnableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.EnableRecommendationPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "EnableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.EnableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "EnableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.EnableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "EnableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// EnableRecommendationPreparer prepares the EnableRecommendation request. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendationPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableRecommendationSender sends the EnableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// EnableRecommendationResponder handles the response to the EnableRecommendation request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// sensitivityLabelSource - the source of the sensitivity label. +func (client ManagedDatabaseSensitivityLabelsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, sensitivityLabelSource) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "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.ManagedDatabaseSensitivityLabelsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseSensitivityLabelsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", sensitivityLabelSource), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", 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 ManagedDatabaseSensitivityLabelsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) GetResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCurrentByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listCurrentByDatabaseNextResults + req, err := client.ListCurrentByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListCurrentByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListCurrentByDatabasePreparer prepares the ListCurrentByDatabase request. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCurrentByDatabaseSender sends the ListCurrentByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCurrentByDatabaseResponder handles the response to the ListCurrentByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listCurrentByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSensitivityLabelsClient) listCurrentByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listCurrentByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListCurrentByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListCurrentByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, filter) + return +} + +// ListRecommendedByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// includeDisabledRecommendations - specifies whether to include disabled recommendations or not. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listRecommendedByDatabaseNextResults + req, err := client.ListRecommendedByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, includeDisabledRecommendations, skipToken, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListRecommendedByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListRecommendedByDatabasePreparer prepares the ListRecommendedByDatabase request. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if includeDisabledRecommendations != nil { + queryParameters["includeDisabledRecommendations"] = autorest.Encode("query", *includeDisabledRecommendations) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListRecommendedByDatabaseSender sends the ListRecommendedByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListRecommendedByDatabaseResponder handles the response to the ListRecommendedByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listRecommendedByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSensitivityLabelsClient) listRecommendedByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listRecommendedByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRecommendedByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListRecommendedByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, includeDisabledRecommendations, skipToken, filter) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go b/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go new file mode 100644 index 000000000000..7c9fb47a1e5f --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go @@ -0,0 +1,300 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient client. +func NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient { + return NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient { + return ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +// parameters - the requested rule baseline resource. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties.BaselineResults", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "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.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "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.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", 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 ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessments.go b/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessments.go new file mode 100644 index 000000000000..888234d2681c --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessments.go @@ -0,0 +1,398 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentsClient 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 ManagedDatabaseVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentsClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentsClient client. +func NewManagedDatabaseVulnerabilityAssessmentsClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentsClient { + return NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentsClient { + return ManagedDatabaseVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "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.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedDatabaseVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "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.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedDatabaseVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists the vulnerability assessments of a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dvalr.Response.Response != nil { + sc = result.dvalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dvalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dvalr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dvalr.hasNextLink() && result.dvalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseVulnerabilityAssessmentListResult) (result DatabaseVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.databaseVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentscans.go b/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentscans.go new file mode 100644 index 000000000000..d5bea2ebbb00 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/manageddatabasevulnerabilityassessmentscans.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentScansClient 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 ManagedDatabaseVulnerabilityAssessmentScansClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentScansClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentScansClient client. +func NewManagedDatabaseVulnerabilityAssessmentScansClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentScansClient { + return NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentScansClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentScansClient { + return ManagedDatabaseVulnerabilityAssessmentScansClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export convert an existing scan result to a human readable format. If already exists nothing happens +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the scanned database. +// scanID - the vulnerability assessment scan Id. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) Export(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.Export") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExportPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure responding to request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a vulnerability assessment scan record of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result VulnerabilityAssessmentScanRecord, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "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.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", 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 ManagedDatabaseVulnerabilityAssessmentScansClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecord, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitiateScan executes a Vulnerability Assessment database scan. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScan(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.InitiateScan") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiateScanPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure preparing request") + return + } + + result, err = client.InitiateScanSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "InitiateScan", result.Response(), "Failure sending request") + return + } + + return +} + +// InitiateScanPreparer prepares the InitiateScan request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateScanSender sends the InitiateScan request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanSender(req *http.Request) (future ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// InitiateScanResponder handles the response to the InitiateScan request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase lists the vulnerability assessment scans of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.vasrlr.Response.Response != nil { + sc = result.vasrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.vasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.vasrlr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.vasrlr.hasNextLink() && result.vasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecordListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) listByDatabaseNextResults(ctx context.Context, lastResults VulnerabilityAssessmentScanRecordListResult) (result VulnerabilityAssessmentScanRecordListResult, err error) { + req, err := lastResults.vulnerabilityAssessmentScanRecordListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstanceadministrators.go b/services/preview/sql/mgmt/v3.0/sql/managedinstanceadministrators.go new file mode 100644 index 000000000000..e4e9e04bda5e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstanceadministrators.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceAdministratorsClient 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 ManagedInstanceAdministratorsClient struct { + BaseClient +} + +// NewManagedInstanceAdministratorsClient creates an instance of the ManagedInstanceAdministratorsClient client. +func NewManagedInstanceAdministratorsClient(subscriptionID string) ManagedInstanceAdministratorsClient { + return NewManagedInstanceAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceAdministratorsClientWithBaseURI creates an instance of the ManagedInstanceAdministratorsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedInstanceAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceAdministratorsClient { + return ManagedInstanceAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested administrator parameters. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAdministrator) (result ManagedInstanceAdministratorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstanceAdministratorProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstanceAdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ManagedInstanceAdministratorProperties.Login", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ManagedInstanceAdministratorProperties.Sid", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceAdministratorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAdministrator) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}", 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 ManagedInstanceAdministratorsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceAdministratorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministratorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceAdministratorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/administrators/{administratorName}", 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 ManagedInstanceAdministratorsClient) DeleteSender(req *http.Request) (future ManagedInstanceAdministratorsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAdministratorsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministrator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "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.ManagedInstanceAdministratorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceAdministratorsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/administrators/{administratorName}", 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 ManagedInstanceAdministratorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) GetResponder(resp *http.Response) (result ManagedInstanceAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance administrators. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAdministratorsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministratorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.ListByInstance") + defer func() { + sc := -1 + if result.mialr.Response.Response != nil { + sc = result.mialr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mialr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mialr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mialr.hasNextLink() && result.mialr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceAdministratorsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/administrators", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAdministratorsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceAdministratorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceAdministratorsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceAdministratorListResult) (result ManagedInstanceAdministratorListResult, err error) { + req, err := lastResults.managedInstanceAdministratorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceAdministratorsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministratorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstanceazureadonlyauthentications.go b/services/preview/sql/mgmt/v3.0/sql/managedinstanceazureadonlyauthentications.go new file mode 100644 index 000000000000..011bc1f2b7c6 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstanceazureadonlyauthentications.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceAzureADOnlyAuthenticationsClient 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 ManagedInstanceAzureADOnlyAuthenticationsClient struct { + BaseClient +} + +// NewManagedInstanceAzureADOnlyAuthenticationsClient creates an instance of the +// ManagedInstanceAzureADOnlyAuthenticationsClient client. +func NewManagedInstanceAzureADOnlyAuthenticationsClient(subscriptionID string) ManagedInstanceAzureADOnlyAuthenticationsClient { + return NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI creates an instance of the +// ManagedInstanceAzureADOnlyAuthenticationsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceAzureADOnlyAuthenticationsClient { + return ManagedInstanceAzureADOnlyAuthenticationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets Server Active Directory only authentication property or updates an existing server Active +// Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the required parameters for creating or updating an Active Directory only authentication +// property. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAzureADOnlyAuthentication) (result ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstanceAzureADOnlyAuthProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstanceAzureADOnlyAuthProperties.AzureADOnlyAuthentication", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAzureADOnlyAuthentication) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", 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 ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", 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 ManagedInstanceAzureADOnlyAuthenticationsClient) DeleteSender(req *http.Request) (future ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a specific Azure Active Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthentication, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "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.ManagedInstanceAzureADOnlyAuthenticationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", 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 ManagedInstanceAzureADOnlyAuthenticationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) GetResponder(resp *http.Response) (result ManagedInstanceAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of server Azure Active Directory only authentications. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.ListByInstance") + defer func() { + sc := -1 + if result.miaaoalr.Response.Response != nil { + sc = result.miaaoalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miaaoalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miaaoalr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miaaoalr.hasNextLink() && result.miaaoalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/azureADOnlyAuthentications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceAzureADOnlyAuthListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceAzureADOnlyAuthListResult) (result ManagedInstanceAzureADOnlyAuthListResult, err error) { + req, err := lastResults.managedInstanceAzureADOnlyAuthListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstanceencryptionprotectors.go b/services/preview/sql/mgmt/v3.0/sql/managedinstanceencryptionprotectors.go new file mode 100644 index 000000000000..d1e8429e5263 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstanceencryptionprotectors.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedInstanceEncryptionProtectorsClient 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 ManagedInstanceEncryptionProtectorsClient struct { + BaseClient +} + +// NewManagedInstanceEncryptionProtectorsClient creates an instance of the ManagedInstanceEncryptionProtectorsClient +// client. +func NewManagedInstanceEncryptionProtectorsClient(subscriptionID string) ManagedInstanceEncryptionProtectorsClient { + return NewManagedInstanceEncryptionProtectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceEncryptionProtectorsClientWithBaseURI creates an instance of the +// ManagedInstanceEncryptionProtectorsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceEncryptionProtectorsClient { + return ManagedInstanceEncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested encryption protector resource state. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceEncryptionProtector) (result ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceEncryptionProtector) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", 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 ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceEncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed instance encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "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.ManagedInstanceEncryptionProtectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceEncryptionProtectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", 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 ManagedInstanceEncryptionProtectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) GetResponder(resp *http.Response) (result ManagedInstanceEncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance encryption protectors +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.ListByInstance") + defer func() { + sc := -1 + if result.mieplr.Response.Response != nil { + sc = result.mieplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mieplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mieplr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mieplr.hasNextLink() && result.mieplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/encryptionProtector", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceEncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceEncryptionProtectorsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceEncryptionProtectorListResult) (result ManagedInstanceEncryptionProtectorListResult, err error) { + req, err := lastResults.managedInstanceEncryptionProtectorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Revalidate revalidates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) Revalidate(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.Revalidate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RevalidatePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Revalidate", nil, "Failure preparing request") + return + } + + result, err = client.RevalidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Revalidate", result.Response(), "Failure sending request") + return + } + + return +} + +// RevalidatePreparer prepares the Revalidate request. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevalidateSender sends the Revalidate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidateSender(req *http.Request) (future ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RevalidateResponder handles the response to the Revalidate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstancekeys.go b/services/preview/sql/mgmt/v3.0/sql/managedinstancekeys.go new file mode 100644 index 000000000000..a4f4e479a482 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstancekeys.go @@ -0,0 +1,403 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedInstanceKeysClient 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 ManagedInstanceKeysClient struct { + BaseClient +} + +// NewManagedInstanceKeysClient creates an instance of the ManagedInstanceKeysClient client. +func NewManagedInstanceKeysClient(subscriptionID string) ManagedInstanceKeysClient { + return NewManagedInstanceKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceKeysClientWithBaseURI creates an instance of the ManagedInstanceKeysClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedInstanceKeysClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceKeysClient { + return ManagedInstanceKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be operated on (updated or created). +// parameters - the requested managed instance key resource state. +func (client ManagedInstanceKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters ManagedInstanceKey) (result ManagedInstanceKeysCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceKeysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters ManagedInstanceKey) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", 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 ManagedInstanceKeysClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceKeysCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed instance key with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be deleted. +func (client ManagedInstanceKeysClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result ManagedInstanceKeysDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/keys/{keyName}", 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 ManagedInstanceKeysClient) DeleteSender(req *http.Request) (future ManagedInstanceKeysDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be retrieved. +func (client ManagedInstanceKeysClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result ManagedInstanceKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "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.ManagedInstanceKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/keys/{keyName}", 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 ManagedInstanceKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) GetResponder(resp *http.Response) (result ManagedInstanceKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance keys. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedInstanceKeysClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result ManagedInstanceKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.ListByInstance") + defer func() { + sc := -1 + if result.miklr.Response.Response != nil { + sc = result.miklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miklr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miklr.hasNextLink() && result.miklr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceKeysClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceKeysClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceKeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceKeysClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceKeyListResult) (result ManagedInstanceKeyListResult, err error) { + req, err := lastResults.managedInstanceKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceKeysClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result ManagedInstanceKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName, filter) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstancelongtermretentionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/managedinstancelongtermretentionpolicies.go new file mode 100644 index 000000000000..d0e380b54953 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstancelongtermretentionpolicies.go @@ -0,0 +1,322 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedInstanceLongTermRetentionPoliciesClient 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 ManagedInstanceLongTermRetentionPoliciesClient struct { + BaseClient +} + +// NewManagedInstanceLongTermRetentionPoliciesClient creates an instance of the +// ManagedInstanceLongTermRetentionPoliciesClient client. +func NewManagedInstanceLongTermRetentionPoliciesClient(subscriptionID string) ManagedInstanceLongTermRetentionPoliciesClient { + return NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI creates an instance of the +// ManagedInstanceLongTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceLongTermRetentionPoliciesClient { + return ManagedInstanceLongTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets a managed database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the long term retention policy info. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedInstanceLongTermRetentionPolicy) (result ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedInstanceLongTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", 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 ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedInstanceLongTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedInstanceLongTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "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.ManagedInstanceLongTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceLongTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", 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 ManagedInstanceLongTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceLongTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedInstanceLongTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.miltrplr.Response.Response != nil { + sc = result.miltrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.miltrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.miltrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.miltrplr.hasNextLink() && result.miltrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedInstanceLongTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionPolicyListResult) (result ManagedInstanceLongTermRetentionPolicyListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedInstanceLongTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstanceoperations.go b/services/preview/sql/mgmt/v3.0/sql/managedinstanceoperations.go new file mode 100644 index 000000000000..66646cac5c47 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstanceoperations.go @@ -0,0 +1,309 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// ManagedInstanceOperationsClient 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 ManagedInstanceOperationsClient struct { + BaseClient +} + +// NewManagedInstanceOperationsClient creates an instance of the ManagedInstanceOperationsClient client. +func NewManagedInstanceOperationsClient(subscriptionID string) ManagedInstanceOperationsClient { + return NewManagedInstanceOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceOperationsClientWithBaseURI creates an instance of the ManagedInstanceOperationsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewManagedInstanceOperationsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceOperationsClient { + return ManagedInstanceOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceOperationsClient) Cancel(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, managedInstanceName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client ManagedInstanceOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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/managedInstances/{managedInstanceName}/operations/{operationId}/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 ManagedInstanceOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ManagedInstanceOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a management operation on a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceOperationsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result ManagedInstanceOperation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "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.ManagedInstanceOperationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceOperationsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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/managedInstances/{managedInstanceName}/operations/{operationId}", 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 ManagedInstanceOperationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceOperationsClient) GetResponder(resp *http.Response) (result ManagedInstanceOperation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedInstance gets a list of operations performed on the managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceOperationsClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.miolr.Response.Response != nil { + sc = result.miolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.miolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.miolr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.miolr.hasNextLink() && result.miolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedInstanceOperationsClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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/managedInstances/{managedInstanceName}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceOperationsClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceOperationsClient) ListByManagedInstanceResponder(resp *http.Response) (result ManagedInstanceOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceOperationsClient) listByManagedInstanceNextResults(ctx context.Context, lastResults ManagedInstanceOperationListResult) (result ManagedInstanceOperationListResult, err error) { + req, err := lastResults.managedInstanceOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceOperationsClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstances.go b/services/preview/sql/mgmt/v3.0/sql/managedinstances.go new file mode 100644 index 000000000000..3116dec56424 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstances.go @@ -0,0 +1,944 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstancesClient 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 ManagedInstancesClient struct { + BaseClient +} + +// NewManagedInstancesClient creates an instance of the ManagedInstancesClient client. +func NewManagedInstancesClient(subscriptionID string) ManagedInstancesClient { + return NewManagedInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstancesClientWithBaseURI creates an instance of the ManagedInstancesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstancesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstancesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstancesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstancesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) DeleteSender(req *http.Request) (future ManagedInstancesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover failovers a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance to failover. +// replicaType - the type of replica to be failed over. +func (client ManagedInstancesClient) Failover(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType ReplicaType) (result ManagedInstancesFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, managedInstanceName, replicaType) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ManagedInstancesClient) FailoverPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType ReplicaType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(replicaType)) > 0 { + queryParameters["replicaType"] = autorest.Encode("query", replicaType) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) FailoverSender(req *http.Request) (future ManagedInstancesFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "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.ManagedInstancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstancesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all managed instances in the subscription. +func (client ManagedInstancesClient) List(ctx context.Context) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.List") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", resp, "Failure sending request") + return + } + + result.milr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ManagedInstancesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListComplete(ctx context.Context) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByInstancePool gets a list of all managed instances in an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the instance pool name. +func (client ManagedInstancesClient) ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstancePoolNextResults + req, err := client.ListByInstancePoolPreparer(ctx, resourceGroupName, instancePoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByInstancePool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByInstancePool", resp, "Failure sending request") + return + } + + result.milr, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByInstancePool", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePoolPreparer prepares the ListByInstancePool request. +func (client ManagedInstancesClient) ListByInstancePoolPreparer(ctx context.Context, resourceGroupName string, instancePoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/instancePools/{instancePoolName}/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstancePoolSender sends the ListByInstancePool request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByInstancePoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstancePoolResponder handles the response to the ListByInstancePool request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByInstancePoolResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstancePoolNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByInstancePoolNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByInstancePoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByInstancePoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByInstancePoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstancePoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstancePool(ctx, resourceGroupName, instancePoolName) + return +} + +// ListByManagedInstance get top resource consuming queries of a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// numberOfQueries - how many 'top queries' to return. Default is 5. +// databases - comma separated list of databases to be included into search. All DB's are included if this +// parameter is not specified. +// startTime - start time for observed period. +// endTime - end time for observed period. +// interval - the time step to be used to summarize the metric values. Default value is PT1H +// aggregationFunction - aggregation function to be used, default value is 'sum' +// observationMetric - metric to be used for ranking top queries. Default is 'cpu' +func (client ManagedInstancesClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval QueryTimeGrainType, aggregationFunction AggregationFunctionType, observationMetric MetricType) (result TopQueriesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.tqlr.Response.Response != nil { + sc = result.tqlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName, numberOfQueries, databases, startTime, endTime, interval, aggregationFunction, observationMetric) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.tqlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.tqlr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.tqlr.hasNextLink() && result.tqlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedInstancesClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval QueryTimeGrainType, aggregationFunction AggregationFunctionType, observationMetric MetricType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if numberOfQueries != nil { + queryParameters["numberOfQueries"] = autorest.Encode("query", *numberOfQueries) + } + if len(databases) > 0 { + queryParameters["databases"] = autorest.Encode("query", databases) + } + if len(startTime) > 0 { + queryParameters["startTime"] = autorest.Encode("query", startTime) + } + if len(endTime) > 0 { + queryParameters["endTime"] = autorest.Encode("query", endTime) + } + if len(string(interval)) > 0 { + queryParameters["interval"] = autorest.Encode("query", interval) + } + if len(string(aggregationFunction)) > 0 { + queryParameters["aggregationFunction"] = autorest.Encode("query", aggregationFunction) + } + if len(string(observationMetric)) > 0 { + queryParameters["observationMetric"] = autorest.Encode("query", observationMetric) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByManagedInstanceResponder(resp *http.Response) (result TopQueriesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByManagedInstanceNextResults(ctx context.Context, lastResults TopQueriesListResult) (result TopQueriesListResult, err error) { + req, err := lastResults.topQueriesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval QueryTimeGrainType, aggregationFunction AggregationFunctionType, observationMetric MetricType) (result TopQueriesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName, numberOfQueries, databases, startTime, endTime, interval, aggregationFunction, observationMetric) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.milr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ManagedInstancesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByResourceGroupResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedInstancesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", 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 ManagedInstancesClient) UpdateSender(req *http.Request) (future ManagedInstancesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstancetdecertificates.go b/services/preview/sql/mgmt/v3.0/sql/managedinstancetdecertificates.go new file mode 100644 index 000000000000..3b0f0fd7c404 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstancetdecertificates.go @@ -0,0 +1,124 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceTdeCertificatesClient 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 ManagedInstanceTdeCertificatesClient struct { + BaseClient +} + +// NewManagedInstanceTdeCertificatesClient creates an instance of the ManagedInstanceTdeCertificatesClient client. +func NewManagedInstanceTdeCertificatesClient(subscriptionID string) ManagedInstanceTdeCertificatesClient { + return NewManagedInstanceTdeCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceTdeCertificatesClientWithBaseURI creates an instance of the ManagedInstanceTdeCertificatesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedInstanceTdeCertificatesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceTdeCertificatesClient { + return ManagedInstanceTdeCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a TDE certificate for a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested TDE certificate to be created or updated. +func (client ManagedInstanceTdeCertificatesClient) Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters TdeCertificate) (result ManagedInstanceTdeCertificatesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceTdeCertificatesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TdeCertificateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TdeCertificateProperties.PrivateBlob", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceTdeCertificatesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ManagedInstanceTdeCertificatesClient) CreatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters TdeCertificate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates", pathParameters), + autorest.WithJSON(parameters), + 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 ManagedInstanceTdeCertificatesClient) CreateSender(req *http.Request) (future ManagedInstanceTdeCertificatesCreateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ManagedInstanceTdeCertificatesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedinstancevulnerabilityassessments.go b/services/preview/sql/mgmt/v3.0/sql/managedinstancevulnerabilityassessments.go new file mode 100644 index 000000000000..f253dcc02c87 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedinstancevulnerabilityassessments.go @@ -0,0 +1,398 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceVulnerabilityAssessmentsClient 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 ManagedInstanceVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewManagedInstanceVulnerabilityAssessmentsClient creates an instance of the +// ManagedInstanceVulnerabilityAssessmentsClient client. +func NewManagedInstanceVulnerabilityAssessmentsClient(subscriptionID string) ManagedInstanceVulnerabilityAssessmentsClient { + return NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// ManagedInstanceVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceVulnerabilityAssessmentsClient { + return ManagedInstanceVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the managed instance's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceVulnerabilityAssessment) (result ManagedInstanceVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstanceVulnerabilityAssessmentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstanceVulnerabilityAssessmentProperties.StorageContainerPath", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "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.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the managed instance's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessment is defined. +func (client ManagedInstanceVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedInstanceVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the managed instance's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessment is defined. +func (client ManagedInstanceVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "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.ManagedInstanceVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ManagedInstanceVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result ManagedInstanceVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets the managed instance's vulnerability assessment policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessments is defined. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.ListByInstance") + defer func() { + sc := -1 + if result.mivalr.Response.Response != nil { + sc = result.mivalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mivalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mivalr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mivalr.hasNextLink() && result.mivalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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/managedInstances/{managedInstanceName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceVulnerabilityAssessmentsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceVulnerabilityAssessmentListResult) (result ManagedInstanceVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.managedInstanceVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go new file mode 100644 index 000000000000..ee0dd38ca42c --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient 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 ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient creates an instance of the +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient client. +func NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient(subscriptionID string) ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient { + return NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient { + return ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the long term retention policy info. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", 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 ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a dropped database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result ManagedBackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "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.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "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/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", 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 ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRestorableDroppedDatabase gets a dropped database's short term retention policy list. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result ManagedBackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.ListByRestorableDroppedDatabase") + defer func() { + sc := -1 + if result.mbstrplr.Response.Response != nil { + sc = result.mbstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByRestorableDroppedDatabaseNextResults + req, err := client.ListByRestorableDroppedDatabasePreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "ListByRestorableDroppedDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRestorableDroppedDatabaseSender(req) + if err != nil { + result.mbstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "ListByRestorableDroppedDatabase", resp, "Failure sending request") + return + } + + result.mbstrplr, err = client.ListByRestorableDroppedDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "ListByRestorableDroppedDatabase", resp, "Failure responding to request") + return + } + if result.mbstrplr.hasNextLink() && result.mbstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByRestorableDroppedDatabasePreparer prepares the ListByRestorableDroppedDatabase request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "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/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRestorableDroppedDatabaseSender sends the ListByRestorableDroppedDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRestorableDroppedDatabaseResponder handles the response to the ListByRestorableDroppedDatabase request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabaseResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByRestorableDroppedDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) listByRestorableDroppedDatabaseNextResults(ctx context.Context, lastResults ManagedBackupShortTermRetentionPolicyListResult) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.managedBackupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "listByRestorableDroppedDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByRestorableDroppedDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "listByRestorableDroppedDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByRestorableDroppedDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "listByRestorableDroppedDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByRestorableDroppedDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result ManagedBackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.ListByRestorableDroppedDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByRestorableDroppedDatabase(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + return +} + +// Update sets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the long term retention policy info. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", 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 ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/managedserversecurityalertpolicies.go b/services/preview/sql/mgmt/v3.0/sql/managedserversecurityalertpolicies.go new file mode 100644 index 000000000000..cda2bb6319b3 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/managedserversecurityalertpolicies.go @@ -0,0 +1,316 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ManagedServerSecurityAlertPoliciesClient 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 ManagedServerSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewManagedServerSecurityAlertPoliciesClient creates an instance of the ManagedServerSecurityAlertPoliciesClient +// client. +func NewManagedServerSecurityAlertPoliciesClient(subscriptionID string) ManagedServerSecurityAlertPoliciesClient { + return NewManagedServerSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedServerSecurityAlertPoliciesClientWithBaseURI creates an instance of the +// ManagedServerSecurityAlertPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedServerSecurityAlertPoliciesClient { + return ManagedServerSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the managed server security alert policy. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedServerSecurityAlertPolicy) (result ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedServerSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", 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 ManagedServerSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a managed server's threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "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.ManagedServerSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedServerSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "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/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", 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 ManagedServerSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ManagedServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance get the managed server's threat detection policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.ListByInstance") + defer func() { + sc := -1 + if result.mssaplr.Response.Response != nil { + sc = result.mssaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mssaplr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mssaplr.hasNextLink() && result.mssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstanceResponder(resp *http.Response) (result ManagedServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedServerSecurityAlertPoliciesClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedServerSecurityAlertPolicyListResult) (result ManagedServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.managedServerSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/models.go b/services/preview/sql/mgmt/v3.0/sql/models.go new file mode 100644 index 000000000000..b67382fd024d --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/models.go @@ -0,0 +1,26683 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v3.0/sql" + +// AdministratorListResult a list of active directory administrators. +type AdministratorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerAzureADAdministrator `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdministratorListResult. +func (alr AdministratorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AdministratorListResultIterator provides access to a complete listing of ServerAzureADAdministrator +// values. +type AdministratorListResultIterator struct { + i int + page AdministratorListResultPage +} + +// NextWithContext 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 *AdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AdministratorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AdministratorListResultIterator) 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 AdministratorListResultIterator) Response() AdministratorListResult { + 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 AdministratorListResultIterator) Value() ServerAzureADAdministrator { + if !iter.page.NotDone() { + return ServerAzureADAdministrator{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AdministratorListResultIterator type. +func NewAdministratorListResultIterator(page AdministratorListResultPage) AdministratorListResultIterator { + return AdministratorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AdministratorListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (alr AdministratorListResult) hasNextLink() bool { + return alr.NextLink != nil && len(*alr.NextLink) != 0 +} + +// administratorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AdministratorListResult) administratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !alr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AdministratorListResultPage contains a page of ServerAzureADAdministrator values. +type AdministratorListResultPage struct { + fn func(context.Context, AdministratorListResult) (AdministratorListResult, error) + alr AdministratorListResult +} + +// NextWithContext 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 *AdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *AdministratorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AdministratorListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AdministratorListResultPage) Response() AdministratorListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AdministratorListResultPage) Values() []ServerAzureADAdministrator { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// Creates a new instance of the AdministratorListResultPage type. +func NewAdministratorListResultPage(cur AdministratorListResult, getNextPage func(context.Context, AdministratorListResult) (AdministratorListResult, error)) AdministratorListResultPage { + return AdministratorListResultPage{ + fn: getNextPage, + alr: cur, + } +} + +// AdministratorProperties properties of a active directory administrator. +type AdministratorProperties struct { + // AdministratorType - Type of the sever administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - Login name of the server administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the server administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // AzureADOnlyAuthentication - READ-ONLY; Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdministratorProperties. +func (ap AdministratorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.AdministratorType != nil { + objectMap["administratorType"] = ap.AdministratorType + } + if ap.Login != nil { + objectMap["login"] = ap.Login + } + if ap.Sid != nil { + objectMap["sid"] = ap.Sid + } + if ap.TenantID != nil { + objectMap["tenantId"] = ap.TenantID + } + return json.Marshal(objectMap) +} + +// 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 - READ-ONLY; Automatic tuning option actual state. Possible values include: 'Off', 'On' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - READ-ONLY; Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - READ-ONLY; Reason description if desired and actual state are different. Possible values include: 'Default', 'Disabled', 'AutoConfigured', 'InheritedFromServer', 'QueryStoreOff', 'QueryStoreReadOnly', 'NotSupported' + ReasonDesc AutomaticTuningDisabledReason `json:"reasonDesc,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomaticTuningOptions. +func (ato AutomaticTuningOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ato.DesiredState != "" { + objectMap["desiredState"] = ato.DesiredState + } + return json.Marshal(objectMap) +} + +// 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 - READ-ONLY; Automatic tuning option actual state. Possible values include: 'Off', 'On' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - READ-ONLY; Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - READ-ONLY; Reason description if desired and actual state are different. Possible values include: 'AutomaticTuningServerReasonDefault', 'AutomaticTuningServerReasonDisabled', 'AutomaticTuningServerReasonAutoConfigured' + ReasonDesc AutomaticTuningServerReason `json:"reasonDesc,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomaticTuningServerOptions. +func (atso AutomaticTuningServerOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atso.DesiredState != "" { + objectMap["desiredState"] = atso.DesiredState + } + return json.Marshal(objectMap) +} + +// 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 - READ-ONLY; 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"` +} + +// MarshalJSON is the custom marshaler for AutomaticTuningServerProperties. +func (atsp AutomaticTuningServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atsp.DesiredState != "" { + objectMap["desiredState"] = atsp.DesiredState + } + if atsp.Options != nil { + objectMap["options"] = atsp.Options + } + return json.Marshal(objectMap) +} + +// AutoPauseDelayTimeRange supported auto pause delay time range +type AutoPauseDelayTimeRange struct { + // MinValue - READ-ONLY; Minimum value + MinValue *int32 `json:"minValue,omitempty"` + // MaxValue - READ-ONLY; Maximum value + MaxValue *int32 `json:"maxValue,omitempty"` + // StepSize - READ-ONLY; Step value for discrete values between the minimum value and the maximum value. + StepSize *int32 `json:"stepSize,omitempty"` + // Default - READ-ONLY; Default value is no value is provided + Default *int32 `json:"default,omitempty"` + // Unit - READ-ONLY; Unit of time that delay is expressed in. Possible values include: 'Minutes' + Unit PauseDelayTimeUnit `json:"unit,omitempty"` + // DoNotPauseValue - READ-ONLY; Value that is used to not pause (infinite delay before pause) + DoNotPauseValue *int32 `json:"doNotPauseValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoPauseDelayTimeRange. +func (apdtr AutoPauseDelayTimeRange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AzureADOnlyAuthListResult a list of active directory only authentications. +type AzureADOnlyAuthListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerAzureADOnlyAuthentication `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureADOnlyAuthListResult. +func (aaoalr AzureADOnlyAuthListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AzureADOnlyAuthListResultIterator provides access to a complete listing of +// ServerAzureADOnlyAuthentication values. +type AzureADOnlyAuthListResultIterator struct { + i int + page AzureADOnlyAuthListResultPage +} + +// NextWithContext 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 *AzureADOnlyAuthListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureADOnlyAuthListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AzureADOnlyAuthListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AzureADOnlyAuthListResultIterator) 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 AzureADOnlyAuthListResultIterator) Response() AzureADOnlyAuthListResult { + 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 AzureADOnlyAuthListResultIterator) Value() ServerAzureADOnlyAuthentication { + if !iter.page.NotDone() { + return ServerAzureADOnlyAuthentication{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AzureADOnlyAuthListResultIterator type. +func NewAzureADOnlyAuthListResultIterator(page AzureADOnlyAuthListResultPage) AzureADOnlyAuthListResultIterator { + return AzureADOnlyAuthListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aaoalr AzureADOnlyAuthListResult) IsEmpty() bool { + return aaoalr.Value == nil || len(*aaoalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aaoalr AzureADOnlyAuthListResult) hasNextLink() bool { + return aaoalr.NextLink != nil && len(*aaoalr.NextLink) != 0 +} + +// azureADOnlyAuthListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aaoalr AzureADOnlyAuthListResult) azureADOnlyAuthListResultPreparer(ctx context.Context) (*http.Request, error) { + if !aaoalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aaoalr.NextLink))) +} + +// AzureADOnlyAuthListResultPage contains a page of ServerAzureADOnlyAuthentication values. +type AzureADOnlyAuthListResultPage struct { + fn func(context.Context, AzureADOnlyAuthListResult) (AzureADOnlyAuthListResult, error) + aaoalr AzureADOnlyAuthListResult +} + +// NextWithContext 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 *AzureADOnlyAuthListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureADOnlyAuthListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.aaoalr) + if err != nil { + return err + } + page.aaoalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *AzureADOnlyAuthListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AzureADOnlyAuthListResultPage) NotDone() bool { + return !page.aaoalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AzureADOnlyAuthListResultPage) Response() AzureADOnlyAuthListResult { + return page.aaoalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AzureADOnlyAuthListResultPage) Values() []ServerAzureADOnlyAuthentication { + if page.aaoalr.IsEmpty() { + return nil + } + return *page.aaoalr.Value +} + +// Creates a new instance of the AzureADOnlyAuthListResultPage type. +func NewAzureADOnlyAuthListResultPage(cur AzureADOnlyAuthListResult, getNextPage func(context.Context, AzureADOnlyAuthListResult) (AzureADOnlyAuthListResult, error)) AzureADOnlyAuthListResultPage { + return AzureADOnlyAuthListResultPage{ + fn: getNextPage, + aaoalr: cur, + } +} + +// AzureADOnlyAuthProperties properties of a active directory only authentication. +type AzureADOnlyAuthProperties struct { + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// BackupLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type BackupLongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupLongTermRetentionPoliciesClient) (BackupLongTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupLongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupLongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *BackupLongTermRetentionPoliciesCreateOrUpdateFuture) result(client BackupLongTermRetentionPoliciesClient) (bltrp BackupLongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bltrp.Response.Response, err = future.GetResult(sender); err == nil && bltrp.Response.Response.StatusCode != http.StatusNoContent { + bltrp, err = client.CreateOrUpdateResponder(bltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", bltrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupLongTermRetentionPolicy a long term retention policy. +type BackupLongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // LongTermRetentionPolicyProperties - Resource properties. + *LongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupLongTermRetentionPolicy. +func (bltrp BackupLongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bltrp.LongTermRetentionPolicyProperties != nil { + objectMap["properties"] = bltrp.LongTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupLongTermRetentionPolicy struct. +func (bltrp *BackupLongTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var longTermRetentionPolicyProperties LongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &longTermRetentionPolicyProperties) + if err != nil { + return err + } + bltrp.LongTermRetentionPolicyProperties = &longTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bltrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bltrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bltrp.Type = &typeVar + } + } + } + + return nil +} + +// BackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type BackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupShortTermRetentionPoliciesClient) (BackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *BackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client BackupShortTermRetentionPoliciesClient) (bstrp BackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bstrp.Response.Response, err = future.GetResult(sender); err == nil && bstrp.Response.Response.StatusCode != http.StatusNoContent { + bstrp, err = client.CreateOrUpdateResponder(bstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", bstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type BackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupShortTermRetentionPoliciesClient) (BackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *BackupShortTermRetentionPoliciesUpdateFuture) result(client BackupShortTermRetentionPoliciesClient) (bstrp BackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bstrp.Response.Response, err = future.GetResult(sender); err == nil && bstrp.Response.Response.StatusCode != http.StatusNoContent { + bstrp, err = client.UpdateResponder(bstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesUpdateFuture", "Result", bstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupShortTermRetentionPolicy a short term retention policy. +type BackupShortTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BackupShortTermRetentionPolicyProperties - Resource properties. + *BackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupShortTermRetentionPolicy. +func (bstrp BackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bstrp.BackupShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = bstrp.BackupShortTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupShortTermRetentionPolicy struct. +func (bstrp *BackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var backupShortTermRetentionPolicyProperties BackupShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &backupShortTermRetentionPolicyProperties) + if err != nil { + return err + } + bstrp.BackupShortTermRetentionPolicyProperties = &backupShortTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bstrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bstrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bstrp.Type = &typeVar + } + } + } + + return nil +} + +// BackupShortTermRetentionPolicyListResult a list of short term retention policies. +type BackupShortTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]BackupShortTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupShortTermRetentionPolicyListResult. +func (bstrplr BackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// BackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of +// BackupShortTermRetentionPolicy values. +type BackupShortTermRetentionPolicyListResultIterator struct { + i int + page BackupShortTermRetentionPolicyListResultPage +} + +// NextWithContext 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 *BackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *BackupShortTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BackupShortTermRetentionPolicyListResultIterator) 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 BackupShortTermRetentionPolicyListResultIterator) Response() BackupShortTermRetentionPolicyListResult { + 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 BackupShortTermRetentionPolicyListResultIterator) Value() BackupShortTermRetentionPolicy { + if !iter.page.NotDone() { + return BackupShortTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the BackupShortTermRetentionPolicyListResultIterator type. +func NewBackupShortTermRetentionPolicyListResultIterator(page BackupShortTermRetentionPolicyListResultPage) BackupShortTermRetentionPolicyListResultIterator { + return BackupShortTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (bstrplr BackupShortTermRetentionPolicyListResult) IsEmpty() bool { + return bstrplr.Value == nil || len(*bstrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (bstrplr BackupShortTermRetentionPolicyListResult) hasNextLink() bool { + return bstrplr.NextLink != nil && len(*bstrplr.NextLink) != 0 +} + +// backupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (bstrplr BackupShortTermRetentionPolicyListResult) backupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !bstrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(bstrplr.NextLink))) +} + +// BackupShortTermRetentionPolicyListResultPage contains a page of BackupShortTermRetentionPolicy values. +type BackupShortTermRetentionPolicyListResultPage struct { + fn func(context.Context, BackupShortTermRetentionPolicyListResult) (BackupShortTermRetentionPolicyListResult, error) + bstrplr BackupShortTermRetentionPolicyListResult +} + +// NextWithContext 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 *BackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.bstrplr) + if err != nil { + return err + } + page.bstrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *BackupShortTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BackupShortTermRetentionPolicyListResultPage) NotDone() bool { + return !page.bstrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BackupShortTermRetentionPolicyListResultPage) Response() BackupShortTermRetentionPolicyListResult { + return page.bstrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BackupShortTermRetentionPolicyListResultPage) Values() []BackupShortTermRetentionPolicy { + if page.bstrplr.IsEmpty() { + return nil + } + return *page.bstrplr.Value +} + +// Creates a new instance of the BackupShortTermRetentionPolicyListResultPage type. +func NewBackupShortTermRetentionPolicyListResultPage(cur BackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, BackupShortTermRetentionPolicyListResult) (BackupShortTermRetentionPolicyListResult, error)) BackupShortTermRetentionPolicyListResultPage { + return BackupShortTermRetentionPolicyListResultPage{ + fn: getNextPage, + bstrplr: cur, + } +} + +// BackupShortTermRetentionPolicyProperties properties of a short term retention policy +type BackupShortTermRetentionPolicyProperties struct { + // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + +// BaseLongTermRetentionPolicyProperties properties of a long term retention policy +type BaseLongTermRetentionPolicyProperties struct { + // WeeklyRetention - The weekly retention policy for an LTR backup in an ISO 8601 format. + WeeklyRetention *string `json:"weeklyRetention,omitempty"` + // MonthlyRetention - The monthly retention policy for an LTR backup in an ISO 8601 format. + MonthlyRetention *string `json:"monthlyRetention,omitempty"` + // YearlyRetention - The yearly retention policy for an LTR backup in an ISO 8601 format. + YearlyRetention *string `json:"yearlyRetention,omitempty"` + // WeekOfYear - The week of year to take the yearly backup in an ISO 8601 format. + WeekOfYear *int32 `json:"weekOfYear,omitempty"` +} + +// CheckNameAvailabilityRequest a request to check whether the specified name for a resource is available. +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResponse the result of a name availability check. +type CheckNameAvailabilityResponse struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The name whose availability was checked. + Name *string `json:"name,omitempty"` + // Available - READ-ONLY; True if the name is available, otherwise false. + Available *bool `json:"available,omitempty"` + // Reason - READ-ONLY; The reason code explaining why the name is unavailable. Will be undefined if the name is available. Possible values include: 'Invalid', 'AlreadyExists' + Reason CheckNameAvailabilityReason `json:"reason,omitempty"` + // Message - READ-ONLY; A message explaining why the name is unavailable. Will be undefined if the name is available. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for CheckNameAvailabilityResponse. +func (cnar CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CompleteDatabaseRestoreDefinition contains the information necessary to perform a complete database +// restore operation. +type CompleteDatabaseRestoreDefinition struct { + // LastBackupName - The last backup name to apply + LastBackupName *string `json:"lastBackupName,omitempty"` +} + +// CreateDatabaseRestorePointDefinition contains the information necessary to perform a create database +// restore point operation. +type CreateDatabaseRestorePointDefinition struct { + // RestorePointLabel - The restore point label to apply + RestorePointLabel *string `json:"restorePointLabel,omitempty"` +} + +// Database a database resource. +type Database struct { + autorest.Response `json:"-"` + // Sku - The database SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or one of the following commands: + // + // ```azurecli + // az sql db list-editions -l -o table + // ```` + // + // ```powershell + // Get-AzSqlServerServiceObjective -Location + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of database. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedBy - READ-ONLY; Resource that manages the database. + ManagedBy *string `json:"managedBy,omitempty"` + // DatabaseProperties - Resource properties. + *DatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.Sku != nil { + objectMap["sku"] = d.Sku + } + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + d.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + d.Kind = &kind + } + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + d.ManagedBy = &managedBy + } + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseAutomaticTuning database-level Automatic Tuning. +type DatabaseAutomaticTuning struct { + autorest.Response `json:"-"` + // DatabaseAutomaticTuningProperties - Resource properties. + *DatabaseAutomaticTuningProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAutomaticTuning. +func (dat DatabaseAutomaticTuning) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dat.DatabaseAutomaticTuningProperties != nil { + objectMap["properties"] = dat.DatabaseAutomaticTuningProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseAutomaticTuningProperties DatabaseAutomaticTuningProperties + err = json.Unmarshal(*v, &databaseAutomaticTuningProperties) + if err != nil { + return err + } + dat.DatabaseAutomaticTuningProperties = &databaseAutomaticTuningProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dat.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dat.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &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 - READ-ONLY; 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"` +} + +// MarshalJSON is the custom marshaler for DatabaseAutomaticTuningProperties. +func (datp DatabaseAutomaticTuningProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if datp.DesiredState != "" { + objectMap["desiredState"] = datp.DesiredState + } + if datp.Options != nil { + objectMap["options"] = datp.Options + } + return json.Marshal(objectMap) +} + +// DatabaseBlobAuditingPolicy a database blob auditing policy. +type DatabaseBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseBlobAuditingPolicyProperties - Resource properties. + *DatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseBlobAuditingPolicy. +func (dbap DatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dbap.DatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = dbap.DatabaseBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseBlobAuditingPolicy struct. +func (dbap *DatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dbap.Kind = &kind + } + case "properties": + if v != nil { + var databaseBlobAuditingPolicyProperties DatabaseBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &databaseBlobAuditingPolicyProperties) + if err != nil { + return err + } + dbap.DatabaseBlobAuditingPolicyProperties = &databaseBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dbap.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseBlobAuditingPolicyListResult a list of database auditing settings. +type DatabaseBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseBlobAuditingPolicyListResult. +func (dbaplr DatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of +// DatabaseBlobAuditingPolicy values. +type DatabaseBlobAuditingPolicyListResultIterator struct { + i int + page DatabaseBlobAuditingPolicyListResultPage +} + +// NextWithContext 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 *DatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseBlobAuditingPolicyListResultIterator) 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 DatabaseBlobAuditingPolicyListResultIterator) Response() DatabaseBlobAuditingPolicyListResult { + 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 DatabaseBlobAuditingPolicyListResultIterator) Value() DatabaseBlobAuditingPolicy { + if !iter.page.NotDone() { + return DatabaseBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseBlobAuditingPolicyListResultIterator type. +func NewDatabaseBlobAuditingPolicyListResultIterator(page DatabaseBlobAuditingPolicyListResultPage) DatabaseBlobAuditingPolicyListResultIterator { + return DatabaseBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dbaplr DatabaseBlobAuditingPolicyListResult) IsEmpty() bool { + return dbaplr.Value == nil || len(*dbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dbaplr DatabaseBlobAuditingPolicyListResult) hasNextLink() bool { + return dbaplr.NextLink != nil && len(*dbaplr.NextLink) != 0 +} + +// databaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dbaplr DatabaseBlobAuditingPolicyListResult) databaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dbaplr.NextLink))) +} + +// DatabaseBlobAuditingPolicyListResultPage contains a page of DatabaseBlobAuditingPolicy values. +type DatabaseBlobAuditingPolicyListResultPage struct { + fn func(context.Context, DatabaseBlobAuditingPolicyListResult) (DatabaseBlobAuditingPolicyListResult, error) + dbaplr DatabaseBlobAuditingPolicyListResult +} + +// NextWithContext 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 *DatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dbaplr) + if err != nil { + return err + } + page.dbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.dbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseBlobAuditingPolicyListResultPage) Response() DatabaseBlobAuditingPolicyListResult { + return page.dbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseBlobAuditingPolicyListResultPage) Values() []DatabaseBlobAuditingPolicy { + if page.dbaplr.IsEmpty() { + return nil + } + return *page.dbaplr.Value +} + +// Creates a new instance of the DatabaseBlobAuditingPolicyListResultPage type. +func NewDatabaseBlobAuditingPolicyListResultPage(cur DatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, DatabaseBlobAuditingPolicyListResult) (DatabaseBlobAuditingPolicyListResult, error)) DatabaseBlobAuditingPolicyListResultPage { + return DatabaseBlobAuditingPolicyListResultPage{ + fn: getNextPage, + dbaplr: cur, + } +} + +// DatabaseBlobAuditingPolicyProperties properties of a database blob auditing policy. +type DatabaseBlobAuditingPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` +} + +// DatabaseListResult a list of databases. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Database `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseListResult. +func (dlr DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// NextWithContext 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 *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListResultIterator) 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 DatabaseListResultIterator) Response() DatabaseListResult { + 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 DatabaseListResultIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListResultIterator type. +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return DatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DatabaseListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(context.Context, DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// NextWithContext 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 *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dlr) + if err != nil { + return err + } + page.dlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListResultPage) Response() DatabaseListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListResultPage) Values() []Database { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DatabaseListResultPage type. +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return DatabaseListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// DatabaseOperation a database operation. +type DatabaseOperation struct { + // DatabaseOperationProperties - Resource properties. + *DatabaseOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperation. +func (do DatabaseOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if do.DatabaseOperationProperties != nil { + objectMap["properties"] = do.DatabaseOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseOperation struct. +func (do *DatabaseOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseOperationProperties DatabaseOperationProperties + err = json.Unmarshal(*v, &databaseOperationProperties) + if err != nil { + return err + } + do.DatabaseOperationProperties = &databaseOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + do.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + do.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + do.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseOperationListResult the response to a list database operations request +type DatabaseOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperationListResult. +func (dolr DatabaseOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseOperationListResultIterator provides access to a complete listing of DatabaseOperation values. +type DatabaseOperationListResultIterator struct { + i int + page DatabaseOperationListResultPage +} + +// NextWithContext 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 *DatabaseOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseOperationListResultIterator) 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 DatabaseOperationListResultIterator) Response() DatabaseOperationListResult { + 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 DatabaseOperationListResultIterator) Value() DatabaseOperation { + if !iter.page.NotDone() { + return DatabaseOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseOperationListResultIterator type. +func NewDatabaseOperationListResultIterator(page DatabaseOperationListResultPage) DatabaseOperationListResultIterator { + return DatabaseOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dolr DatabaseOperationListResult) IsEmpty() bool { + return dolr.Value == nil || len(*dolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dolr DatabaseOperationListResult) hasNextLink() bool { + return dolr.NextLink != nil && len(*dolr.NextLink) != 0 +} + +// databaseOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dolr DatabaseOperationListResult) databaseOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dolr.NextLink))) +} + +// DatabaseOperationListResultPage contains a page of DatabaseOperation values. +type DatabaseOperationListResultPage struct { + fn func(context.Context, DatabaseOperationListResult) (DatabaseOperationListResult, error) + dolr DatabaseOperationListResult +} + +// NextWithContext 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 *DatabaseOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dolr) + if err != nil { + return err + } + page.dolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseOperationListResultPage) NotDone() bool { + return !page.dolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseOperationListResultPage) Response() DatabaseOperationListResult { + return page.dolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseOperationListResultPage) Values() []DatabaseOperation { + if page.dolr.IsEmpty() { + return nil + } + return *page.dolr.Value +} + +// Creates a new instance of the DatabaseOperationListResultPage type. +func NewDatabaseOperationListResultPage(cur DatabaseOperationListResult, getNextPage func(context.Context, DatabaseOperationListResult) (DatabaseOperationListResult, error)) DatabaseOperationListResultPage { + return DatabaseOperationListResultPage{ + fn: getNextPage, + dolr: cur, + } +} + +// DatabaseOperationProperties the properties of a database operation. +type DatabaseOperationProperties struct { + // DatabaseName - READ-ONLY; The name of the database the operation is being performed on. + DatabaseName *string `json:"databaseName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperationProperties. +func (dop DatabaseOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseProperties the database's properties. +type DatabaseProperties struct { + // CreateMode - Specifies the mode of database creation. + // + // Default: regular database creation. + // + // Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database. + // + // Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database. + // + // PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified. + // + // 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, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'CreateModeDefault', 'CreateModeCopy', 'CreateModeSecondary', 'CreateModePointInTimeRestore', 'CreateModeRestore', 'CreateModeRecovery', 'CreateModeRestoreExternalBackup', 'CreateModeRestoreExternalBackupSecondary', 'CreateModeRestoreLongTermRetentionBackup', 'CreateModeOnlineSecondary' + CreateMode CreateMode `json:"createMode,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` + // MaxSizeBytes - The max size of the database expressed in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // SampleName - The name of the sample schema to apply when creating this database. Possible values include: 'AdventureWorksLT', 'WideWorldImportersStd', 'WideWorldImportersFull' + SampleName SampleName `json:"sampleName,omitempty"` + // ElasticPoolID - The resource identifier of the elastic pool containing this database. + ElasticPoolID *string `json:"elasticPoolId,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled' + Status DatabaseStatus `json:"status,omitempty"` + // DatabaseID - READ-ONLY; The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // CurrentServiceObjectiveName - READ-ONLY; The current service level objective name of the database. + CurrentServiceObjectiveName *string `json:"currentServiceObjectiveName,omitempty"` + // RequestedServiceObjectiveName - READ-ONLY; The requested service level objective name of the database. + RequestedServiceObjectiveName *string `json:"requestedServiceObjectiveName,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // FailoverGroupID - READ-ONLY; Failover Group resource identifier that this database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // SourceDatabaseDeletionDate - Specifies the time that the database was deleted. + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + // RecoveryServicesRecoveryPointID - The resource identifier of the recovery point associated with create operation of this database. + RecoveryServicesRecoveryPointID *string `json:"recoveryServicesRecoveryPointId,omitempty"` + // LongTermRetentionBackupResourceID - The resource identifier of the long term retention backup associated with create operation of this database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The resource identifier of the restorable dropped database associated with create operation of this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'DATABASEDEFAULT', 'SQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // ZoneRedundant - Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this database. `LicenseIncluded` if you need a license, or `BasePrice` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: 'LicenseIncluded', 'BasePrice' + LicenseType DatabaseLicenseType `json:"licenseType,omitempty"` + // MaxLogSizeBytes - READ-ONLY; The max log size for this database. + MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` + // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // ReadScale - The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' + ReadScale DatabaseReadScale `json:"readScale,omitempty"` + // ReadReplicaCount - The number of readonly secondary replicas associated with the database. + ReadReplicaCount *int32 `json:"readReplicaCount,omitempty"` + // CurrentSku - READ-ONLY; The name and tier of the SKU. + CurrentSku *Sku `json:"currentSku,omitempty"` + // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled + AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` + // StorageAccountType - The storage account type used to store backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' + StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` + // MinCapacity - Minimal capacity that database will always have allocated, if not paused + MinCapacity *float64 `json:"minCapacity,omitempty"` + // PausedDate - READ-ONLY; The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. + PausedDate *date.Time `json:"pausedDate,omitempty"` + // ResumedDate - READ-ONLY; The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. + ResumedDate *date.Time `json:"resumedDate,omitempty"` + // SourceResourceID - The resource identifier of the source associated with the create operation of this database. + // + // When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode must be PointInTimeRestore, Restore or Recover. + // + // When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of an existing database or existing sql pool, and restorePointInTime must be specified. + // + // When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped database or restorable dropped sql pool. + // + // When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or recoverable sql pool. + // + // This property allows to restore across subscriptions which is only supported for DataWarehouse edition. + // + // When source subscription belongs to a different tenant than target subscription, “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. For more details about “x-ms-authorization-auxiliary” header see https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant + SourceResourceID *string `json:"sourceResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseProperties. +func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.CreateMode != "" { + objectMap["createMode"] = dp.CreateMode + } + if dp.Collation != nil { + objectMap["collation"] = dp.Collation + } + if dp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = dp.MaxSizeBytes + } + if dp.SampleName != "" { + objectMap["sampleName"] = dp.SampleName + } + if dp.ElasticPoolID != nil { + objectMap["elasticPoolId"] = dp.ElasticPoolID + } + if dp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = dp.SourceDatabaseID + } + if dp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = dp.RestorePointInTime + } + if dp.SourceDatabaseDeletionDate != nil { + objectMap["sourceDatabaseDeletionDate"] = dp.SourceDatabaseDeletionDate + } + if dp.RecoveryServicesRecoveryPointID != nil { + objectMap["recoveryServicesRecoveryPointId"] = dp.RecoveryServicesRecoveryPointID + } + if dp.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = dp.LongTermRetentionBackupResourceID + } + if dp.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = dp.RecoverableDatabaseID + } + if dp.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = dp.RestorableDroppedDatabaseID + } + if dp.CatalogCollation != "" { + objectMap["catalogCollation"] = dp.CatalogCollation + } + if dp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = dp.ZoneRedundant + } + if dp.LicenseType != "" { + objectMap["licenseType"] = dp.LicenseType + } + if dp.ReadScale != "" { + objectMap["readScale"] = dp.ReadScale + } + if dp.ReadReplicaCount != nil { + objectMap["readReplicaCount"] = dp.ReadReplicaCount + } + if dp.AutoPauseDelay != nil { + objectMap["autoPauseDelay"] = dp.AutoPauseDelay + } + if dp.StorageAccountType != "" { + objectMap["storageAccountType"] = dp.StorageAccountType + } + if dp.MinCapacity != nil { + objectMap["minCapacity"] = dp.MinCapacity + } + if dp.SourceResourceID != nil { + objectMap["sourceResourceId"] = dp.SourceResourceID + } + return json.Marshal(objectMap) +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesCreateOrUpdateFuture.Result. +func (future *DatabasesCreateOrUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesDeleteFuture.Result. +func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseSecurityAlertPolicy contains information about a database Threat Detection policy. +type DatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseSecurityAlertPolicyProperties - Properties of the security alert policy. + *DatabaseSecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseSecurityAlertPolicy. +func (dsap DatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsap.Location != nil { + objectMap["location"] = dsap.Location + } + if dsap.DatabaseSecurityAlertPolicyProperties != nil { + objectMap["properties"] = dsap.DatabaseSecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseSecurityAlertPolicy struct. +func (dsap *DatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dsap.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dsap.Kind = &kind + } + case "properties": + if v != nil { + var databaseSecurityAlertPolicyProperties DatabaseSecurityAlertPolicyProperties + err = json.Unmarshal(*v, &databaseSecurityAlertPolicyProperties) + if err != nil { + return err + } + dsap.DatabaseSecurityAlertPolicyProperties = &databaseSecurityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dsap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dsap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dsap.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseSecurityAlertPolicyProperties properties for a database Threat Detection policy. +type DatabaseSecurityAlertPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint and storageAccountAccessKey are required. Possible values include: 'SecurityAlertPolicyStateNew', 'SecurityAlertPolicyStateEnabled', 'SecurityAlertPolicyStateDisabled' + State SecurityAlertPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies the semicolon-separated list of alerts that are disabled, or empty string to disable no alerts. Possible values: Sql_Injection; Sql_Injection_Vulnerability; Access_Anomaly; Data_Exfiltration; Unsafe_Action. + DisabledAlerts *string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies the semicolon-separated list of e-mail addresses to which the alert is sent. + EmailAddresses *string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. Possible values include: 'SecurityAlertPolicyEmailAccountAdminsEnabled', 'SecurityAlertPolicyEmailAccountAdminsDisabled' + EmailAccountAdmins SecurityAlertPolicyEmailAccountAdmins `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. If state is Enabled, storageEndpoint is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. If state is Enabled, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // UseServerDefault - Specifies whether to use the default server policy. Possible values include: 'SecurityAlertPolicyUseServerDefaultEnabled', 'SecurityAlertPolicyUseServerDefaultDisabled' + UseServerDefault SecurityAlertPolicyUseServerDefault `json:"useServerDefault,omitempty"` +} + +// DatabasesExportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesExportFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (ImportExportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesExportFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesExportFuture.Result. +func (future *DatabasesExportFuture) result(client DatabasesClient) (ieor ImportExportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ExportResponder(ieor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", ieor.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesFailoverFuture.Result. +func (future *DatabasesFailoverFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesPauseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesPauseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesPauseFuture.Result. +func (future *DatabasesPauseFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.PauseResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesResumeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesResumeFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesResumeFuture.Result. +func (future *DatabasesResumeFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.ResumeResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpdateFuture.Result. +func (future *DatabasesUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesUpgradeDataWarehouseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabasesUpgradeDataWarehouseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpgradeDataWarehouseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpgradeDataWarehouseFuture.Result. +func (future *DatabasesUpgradeDataWarehouseFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpgradeDataWarehouseFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseUpdate a database update resource. +type DatabaseUpdate struct { + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // DatabaseUpdateProperties - Resource properties. + *DatabaseUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DatabaseUpdate. +func (du DatabaseUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if du.Sku != nil { + objectMap["sku"] = du.Sku + } + if du.DatabaseUpdateProperties != nil { + objectMap["properties"] = du.DatabaseUpdateProperties + } + if du.Tags != nil { + objectMap["tags"] = du.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseUpdate struct. +func (du *DatabaseUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + du.Sku = &sku + } + case "properties": + if v != nil { + var databaseUpdateProperties DatabaseUpdateProperties + err = json.Unmarshal(*v, &databaseUpdateProperties) + if err != nil { + return err + } + du.DatabaseUpdateProperties = &databaseUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + du.Tags = tags + } + } + } + + return nil +} + +// DatabaseUpdateProperties a database update properties. +type DatabaseUpdateProperties struct { + // CreateMode - Specifies the mode of database creation. + // + // Default: regular database creation. + // + // Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database. + // + // Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database. + // + // PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified. + // + // 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, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'CreateModeDefault', 'CreateModeCopy', 'CreateModeSecondary', 'CreateModePointInTimeRestore', 'CreateModeRestore', 'CreateModeRecovery', 'CreateModeRestoreExternalBackup', 'CreateModeRestoreExternalBackupSecondary', 'CreateModeRestoreLongTermRetentionBackup', 'CreateModeOnlineSecondary' + CreateMode CreateMode `json:"createMode,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` + // MaxSizeBytes - The max size of the database expressed in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // SampleName - The name of the sample schema to apply when creating this database. Possible values include: 'AdventureWorksLT', 'WideWorldImportersStd', 'WideWorldImportersFull' + SampleName SampleName `json:"sampleName,omitempty"` + // ElasticPoolID - The resource identifier of the elastic pool containing this database. + ElasticPoolID *string `json:"elasticPoolId,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled' + Status DatabaseStatus `json:"status,omitempty"` + // DatabaseID - READ-ONLY; The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // CurrentServiceObjectiveName - READ-ONLY; The current service level objective name of the database. + CurrentServiceObjectiveName *string `json:"currentServiceObjectiveName,omitempty"` + // RequestedServiceObjectiveName - READ-ONLY; The requested service level objective name of the database. + RequestedServiceObjectiveName *string `json:"requestedServiceObjectiveName,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // FailoverGroupID - READ-ONLY; Failover Group resource identifier that this database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // SourceDatabaseDeletionDate - Specifies the time that the database was deleted. + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + // RecoveryServicesRecoveryPointID - The resource identifier of the recovery point associated with create operation of this database. + RecoveryServicesRecoveryPointID *string `json:"recoveryServicesRecoveryPointId,omitempty"` + // LongTermRetentionBackupResourceID - The resource identifier of the long term retention backup associated with create operation of this database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The resource identifier of the restorable dropped database associated with create operation of this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'DATABASEDEFAULT', 'SQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // ZoneRedundant - Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this database. `LicenseIncluded` if you need a license, or `BasePrice` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: 'LicenseIncluded', 'BasePrice' + LicenseType DatabaseLicenseType `json:"licenseType,omitempty"` + // MaxLogSizeBytes - READ-ONLY; The max log size for this database. + MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` + // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // ReadScale - The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' + ReadScale DatabaseReadScale `json:"readScale,omitempty"` + // ReadReplicaCount - The number of readonly secondary replicas associated with the database. + ReadReplicaCount *int32 `json:"readReplicaCount,omitempty"` + // CurrentSku - READ-ONLY; The name and tier of the SKU. + CurrentSku *Sku `json:"currentSku,omitempty"` + // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled + AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` + // StorageAccountType - The storage account type used to store backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' + StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` + // MinCapacity - Minimal capacity that database will always have allocated, if not paused + MinCapacity *float64 `json:"minCapacity,omitempty"` + // PausedDate - READ-ONLY; The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. + PausedDate *date.Time `json:"pausedDate,omitempty"` + // ResumedDate - READ-ONLY; The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. + ResumedDate *date.Time `json:"resumedDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUpdateProperties. +func (dup DatabaseUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dup.CreateMode != "" { + objectMap["createMode"] = dup.CreateMode + } + if dup.Collation != nil { + objectMap["collation"] = dup.Collation + } + if dup.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = dup.MaxSizeBytes + } + if dup.SampleName != "" { + objectMap["sampleName"] = dup.SampleName + } + if dup.ElasticPoolID != nil { + objectMap["elasticPoolId"] = dup.ElasticPoolID + } + if dup.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = dup.SourceDatabaseID + } + if dup.RestorePointInTime != nil { + objectMap["restorePointInTime"] = dup.RestorePointInTime + } + if dup.SourceDatabaseDeletionDate != nil { + objectMap["sourceDatabaseDeletionDate"] = dup.SourceDatabaseDeletionDate + } + if dup.RecoveryServicesRecoveryPointID != nil { + objectMap["recoveryServicesRecoveryPointId"] = dup.RecoveryServicesRecoveryPointID + } + if dup.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = dup.LongTermRetentionBackupResourceID + } + if dup.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = dup.RecoverableDatabaseID + } + if dup.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = dup.RestorableDroppedDatabaseID + } + if dup.CatalogCollation != "" { + objectMap["catalogCollation"] = dup.CatalogCollation + } + if dup.ZoneRedundant != nil { + objectMap["zoneRedundant"] = dup.ZoneRedundant + } + if dup.LicenseType != "" { + objectMap["licenseType"] = dup.LicenseType + } + if dup.ReadScale != "" { + objectMap["readScale"] = dup.ReadScale + } + if dup.ReadReplicaCount != nil { + objectMap["readReplicaCount"] = dup.ReadReplicaCount + } + if dup.AutoPauseDelay != nil { + objectMap["autoPauseDelay"] = dup.AutoPauseDelay + } + if dup.StorageAccountType != "" { + objectMap["storageAccountType"] = dup.StorageAccountType + } + if dup.MinCapacity != nil { + objectMap["minCapacity"] = dup.MinCapacity + } + return json.Marshal(objectMap) +} + +// DatabaseUsage the database usages. +type DatabaseUsage struct { + // Name - READ-ONLY; The name of the usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - READ-ONLY; The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - READ-ONLY; The usage metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; The current value of the usage metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; The current limit of the usage metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units of the usage metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - READ-ONLY; The next reset time for the usage metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUsage. +func (du DatabaseUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseUsageListResult the response to a list database metrics request. +type DatabaseUsageListResult struct { + autorest.Response `json:"-"` + // Value - The list of database usages for the database. + Value *[]DatabaseUsage `json:"value,omitempty"` +} + +// DatabaseVulnerabilityAssessment a database vulnerability assessment. +type DatabaseVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentProperties - Resource properties. + *DatabaseVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessment. +func (dva DatabaseVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dva.DatabaseVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = dva.DatabaseVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessment struct. +func (dva *DatabaseVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentProperties DatabaseVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentProperties) + if err != nil { + return err + } + dva.DatabaseVulnerabilityAssessmentProperties = &databaseVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dva.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentListResult a list of the database's vulnerability assessments. +type DatabaseVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentListResult. +func (dvalr DatabaseVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// DatabaseVulnerabilityAssessment values. +type DatabaseVulnerabilityAssessmentListResultIterator struct { + i int + page DatabaseVulnerabilityAssessmentListResultPage +} + +// NextWithContext 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 *DatabaseVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseVulnerabilityAssessmentListResultIterator) 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 DatabaseVulnerabilityAssessmentListResultIterator) Response() DatabaseVulnerabilityAssessmentListResult { + 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 DatabaseVulnerabilityAssessmentListResultIterator) Value() DatabaseVulnerabilityAssessment { + if !iter.page.NotDone() { + return DatabaseVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseVulnerabilityAssessmentListResultIterator type. +func NewDatabaseVulnerabilityAssessmentListResultIterator(page DatabaseVulnerabilityAssessmentListResultPage) DatabaseVulnerabilityAssessmentListResultIterator { + return DatabaseVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dvalr DatabaseVulnerabilityAssessmentListResult) IsEmpty() bool { + return dvalr.Value == nil || len(*dvalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dvalr DatabaseVulnerabilityAssessmentListResult) hasNextLink() bool { + return dvalr.NextLink != nil && len(*dvalr.NextLink) != 0 +} + +// databaseVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dvalr DatabaseVulnerabilityAssessmentListResult) databaseVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dvalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dvalr.NextLink))) +} + +// DatabaseVulnerabilityAssessmentListResultPage contains a page of DatabaseVulnerabilityAssessment values. +type DatabaseVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, DatabaseVulnerabilityAssessmentListResult) (DatabaseVulnerabilityAssessmentListResult, error) + dvalr DatabaseVulnerabilityAssessmentListResult +} + +// NextWithContext 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 *DatabaseVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dvalr) + if err != nil { + return err + } + page.dvalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.dvalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseVulnerabilityAssessmentListResultPage) Response() DatabaseVulnerabilityAssessmentListResult { + return page.dvalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseVulnerabilityAssessmentListResultPage) Values() []DatabaseVulnerabilityAssessment { + if page.dvalr.IsEmpty() { + return nil + } + return *page.dvalr.Value +} + +// Creates a new instance of the DatabaseVulnerabilityAssessmentListResultPage type. +func NewDatabaseVulnerabilityAssessmentListResultPage(cur DatabaseVulnerabilityAssessmentListResult, getNextPage func(context.Context, DatabaseVulnerabilityAssessmentListResult) (DatabaseVulnerabilityAssessmentListResult, error)) DatabaseVulnerabilityAssessmentListResultPage { + return DatabaseVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + dvalr: cur, + } +} + +// DatabaseVulnerabilityAssessmentProperties properties of a database Vulnerability Assessment. +type DatabaseVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). It is required if server level vulnerability assessment policy doesn't set + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has read and write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// DatabaseVulnerabilityAssessmentRuleBaseline a database vulnerability assessment rule baseline. +type DatabaseVulnerabilityAssessmentRuleBaseline struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentRuleBaselineProperties - Resource properties. + *DatabaseVulnerabilityAssessmentRuleBaselineProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentRuleBaseline. +func (dvarb DatabaseVulnerabilityAssessmentRuleBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties != nil { + objectMap["properties"] = dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessmentRuleBaseline struct. +func (dvarb *DatabaseVulnerabilityAssessmentRuleBaseline) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentRuleBaselineProperties DatabaseVulnerabilityAssessmentRuleBaselineProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentRuleBaselineProperties) + if err != nil { + return err + } + dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties = &databaseVulnerabilityAssessmentRuleBaselineProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dvarb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dvarb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dvarb.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentRuleBaselineItem properties for an Azure SQL Database Vulnerability +// Assessment rule baseline's result. +type DatabaseVulnerabilityAssessmentRuleBaselineItem struct { + // Result - The rule baseline result + Result *[]string `json:"result,omitempty"` +} + +// DatabaseVulnerabilityAssessmentRuleBaselineProperties properties of a database Vulnerability Assessment +// rule baseline. +type DatabaseVulnerabilityAssessmentRuleBaselineProperties struct { + // BaselineResults - The rule baseline result + BaselineResults *[]DatabaseVulnerabilityAssessmentRuleBaselineItem `json:"baselineResults,omitempty"` +} + +// DatabaseVulnerabilityAssessmentScanExportProperties properties of the export operation's result. +type DatabaseVulnerabilityAssessmentScanExportProperties struct { + // ExportedReportLocation - READ-ONLY; Location of the exported report (e.g. https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). + ExportedReportLocation *string `json:"exportedReportLocation,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentScanExportProperties. +func (dvasep DatabaseVulnerabilityAssessmentScanExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessmentScansExport a database Vulnerability Assessment scan export resource. +type DatabaseVulnerabilityAssessmentScansExport struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentScanExportProperties - Resource properties. + *DatabaseVulnerabilityAssessmentScanExportProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentScansExport. +func (dvase DatabaseVulnerabilityAssessmentScansExport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dvase.DatabaseVulnerabilityAssessmentScanExportProperties != nil { + objectMap["properties"] = dvase.DatabaseVulnerabilityAssessmentScanExportProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessmentScansExport struct. +func (dvase *DatabaseVulnerabilityAssessmentScansExport) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentScanExportProperties DatabaseVulnerabilityAssessmentScanExportProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentScanExportProperties) + if err != nil { + return err + } + dvase.DatabaseVulnerabilityAssessmentScanExportProperties = &databaseVulnerabilityAssessmentScanExportProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dvase.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dvase.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dvase.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type DatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *DatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client DatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return +} + +// DataMaskingPolicy represents a database data masking policy. +type DataMaskingPolicy struct { + autorest.Response `json:"-"` + // DataMaskingPolicyProperties - The properties of the data masking policy. + *DataMaskingPolicyProperties `json:"properties,omitempty"` + // Location - READ-ONLY; The location of the data masking policy. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; The kind of data masking policy. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingPolicy. +func (dmp DataMaskingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmp.DataMaskingPolicyProperties != nil { + objectMap["properties"] = dmp.DataMaskingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataMaskingPolicy struct. +func (dmp *DataMaskingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataMaskingPolicyProperties DataMaskingPolicyProperties + err = json.Unmarshal(*v, &dataMaskingPolicyProperties) + if err != nil { + return err + } + dmp.DataMaskingPolicyProperties = &dataMaskingPolicyProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dmp.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dmp.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dmp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dmp.Type = &typeVar + } + } + } + + return nil +} + +// DataMaskingPolicyProperties the properties of a database data masking policy. +type DataMaskingPolicyProperties struct { + // DataMaskingState - The state of the data masking policy. Possible values include: 'DataMaskingStateDisabled', 'DataMaskingStateEnabled' + DataMaskingState DataMaskingState `json:"dataMaskingState,omitempty"` + // ExemptPrincipals - The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users receive data results without masking for all of the database queries. + ExemptPrincipals *string `json:"exemptPrincipals,omitempty"` + // ApplicationPrincipals - READ-ONLY; The list of the application principals. This is a legacy parameter and is no longer used. + ApplicationPrincipals *string `json:"applicationPrincipals,omitempty"` + // MaskingLevel - READ-ONLY; The masking level. This is a legacy parameter and is no longer used. + MaskingLevel *string `json:"maskingLevel,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingPolicyProperties. +func (dmpp DataMaskingPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmpp.DataMaskingState != "" { + objectMap["dataMaskingState"] = dmpp.DataMaskingState + } + if dmpp.ExemptPrincipals != nil { + objectMap["exemptPrincipals"] = dmpp.ExemptPrincipals + } + return json.Marshal(objectMap) +} + +// DataMaskingRule represents a database data masking rule. +type DataMaskingRule struct { + autorest.Response `json:"-"` + // DataMaskingRuleProperties - The properties of the resource. + *DataMaskingRuleProperties `json:"properties,omitempty"` + // Location - READ-ONLY; The location of the data masking rule. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; The kind of Data Masking Rule. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingRule. +func (dmr DataMaskingRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmr.DataMaskingRuleProperties != nil { + objectMap["properties"] = dmr.DataMaskingRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataMaskingRule struct. +func (dmr *DataMaskingRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataMaskingRuleProperties DataMaskingRuleProperties + err = json.Unmarshal(*v, &dataMaskingRuleProperties) + if err != nil { + return err + } + dmr.DataMaskingRuleProperties = &dataMaskingRuleProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dmr.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dmr.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dmr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dmr.Type = &typeVar + } + } + } + + return nil +} + +// DataMaskingRuleListResult the response to a list data masking rules request. +type DataMaskingRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of database data masking rules. + Value *[]DataMaskingRule `json:"value,omitempty"` +} + +// DataMaskingRuleProperties the properties of a database data masking rule. +type DataMaskingRuleProperties struct { + // ID - READ-ONLY; The rule Id. + ID *string `json:"id,omitempty"` + // AliasName - The alias name. This is a legacy parameter and is no longer used. + AliasName *string `json:"aliasName,omitempty"` + // RuleState - The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState. Possible values include: 'DataMaskingRuleStateDisabled', 'DataMaskingRuleStateEnabled' + RuleState DataMaskingRuleState `json:"ruleState,omitempty"` + // SchemaName - The schema name on which the data masking rule is applied. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - The table name on which the data masking rule is applied. + TableName *string `json:"tableName,omitempty"` + // ColumnName - The column name on which the data masking rule is applied. + ColumnName *string `json:"columnName,omitempty"` + // MaskingFunction - The masking function that is used for the data masking rule. Possible values include: 'DataMaskingFunctionDefault', 'DataMaskingFunctionCCN', 'DataMaskingFunctionEmail', 'DataMaskingFunctionNumber', 'DataMaskingFunctionSSN', 'DataMaskingFunctionText' + MaskingFunction DataMaskingFunction `json:"maskingFunction,omitempty"` + // NumberFrom - The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. + NumberFrom *string `json:"numberFrom,omitempty"` + // NumberTo - The numberTo property of the data masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. + NumberTo *string `json:"numberTo,omitempty"` + // PrefixSize - If maskingFunction is set to Text, the number of characters to show unmasked in the beginning of the string. Otherwise, this parameter will be ignored. + PrefixSize *string `json:"prefixSize,omitempty"` + // SuffixSize - If maskingFunction is set to Text, the number of characters to show unmasked at the end of the string. Otherwise, this parameter will be ignored. + SuffixSize *string `json:"suffixSize,omitempty"` + // ReplacementString - If maskingFunction is set to Text, the character to use for masking the unexposed part of the string. Otherwise, this parameter will be ignored. + ReplacementString *string `json:"replacementString,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingRuleProperties. +func (dmrp DataMaskingRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmrp.AliasName != nil { + objectMap["aliasName"] = dmrp.AliasName + } + if dmrp.RuleState != "" { + objectMap["ruleState"] = dmrp.RuleState + } + if dmrp.SchemaName != nil { + objectMap["schemaName"] = dmrp.SchemaName + } + if dmrp.TableName != nil { + objectMap["tableName"] = dmrp.TableName + } + if dmrp.ColumnName != nil { + objectMap["columnName"] = dmrp.ColumnName + } + if dmrp.MaskingFunction != "" { + objectMap["maskingFunction"] = dmrp.MaskingFunction + } + if dmrp.NumberFrom != nil { + objectMap["numberFrom"] = dmrp.NumberFrom + } + if dmrp.NumberTo != nil { + objectMap["numberTo"] = dmrp.NumberTo + } + if dmrp.PrefixSize != nil { + objectMap["prefixSize"] = dmrp.PrefixSize + } + if dmrp.SuffixSize != nil { + objectMap["suffixSize"] = dmrp.SuffixSize + } + if dmrp.ReplacementString != nil { + objectMap["replacementString"] = dmrp.ReplacementString + } + return json.Marshal(objectMap) +} + +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - READ-ONLY; The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - READ-ONLY; The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // ReadScale - READ-ONLY; The read scale capability for the edition. + ReadScale *ReadScaleCapability `json:"readScale,omitempty"` + // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition + SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for EditionCapability. +func (ec EditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.Reason != nil { + objectMap["reason"] = ec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPool an elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // Sku - The elastic pool SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or the following command: + // + // ```azurecli + // az sql elastic-pool list-editions -l -o table + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ElasticPoolProperties - Resource properties. + *ElasticPoolProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPool. +func (ep ElasticPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.Sku != nil { + objectMap["sku"] = ep.Sku + } + if ep.ElasticPoolProperties != nil { + objectMap["properties"] = ep.ElasticPoolProperties + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPool struct. +func (ep *ElasticPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ep.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "properties": + if v != nil { + var elasticPoolProperties ElasticPoolProperties + err = json.Unmarshal(*v, &elasticPoolProperties) + if err != nil { + return err + } + ep.ElasticPoolProperties = &elasticPoolProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolActivity represents the activity on an elastic pool. +type ElasticPoolActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolActivityProperties - The properties representing the resource. + *ElasticPoolActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolActivity. +func (epa ElasticPoolActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epa.Location != nil { + objectMap["location"] = epa.Location + } + if epa.ElasticPoolActivityProperties != nil { + objectMap["properties"] = epa.ElasticPoolActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolActivity struct. +func (epa *ElasticPoolActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epa.Location = &location + } + case "properties": + if v != nil { + var elasticPoolActivityProperties ElasticPoolActivityProperties + err = json.Unmarshal(*v, &elasticPoolActivityProperties) + if err != nil { + return err + } + epa.ElasticPoolActivityProperties = &elasticPoolActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epa.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolActivityListResult represents the response to a list elastic pool activity request. +type ElasticPoolActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool activities. + Value *[]ElasticPoolActivity `json:"value,omitempty"` +} + +// ElasticPoolActivityProperties represents the properties of an elastic pool. +type ElasticPoolActivityProperties struct { + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedDatabaseDtuMax - READ-ONLY; The requested max DTU per database if available. + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + // RequestedDatabaseDtuMin - READ-ONLY; The requested min DTU per database if available. + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + // RequestedDtu - READ-ONLY; The requested DTU for the pool if available. + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The requested name for the elastic pool if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // RequestedStorageLimitInGB - READ-ONLY; The requested storage limit for the pool in GB if available. + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + // ElasticPoolName - READ-ONLY; The name of the elastic pool. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` + // RequestedStorageLimitInMB - READ-ONLY; The requested storage limit in MB. + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + // RequestedDatabaseDtuGuarantee - READ-ONLY; The requested per database DTU guarantee. + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + // RequestedDatabaseDtuCap - READ-ONLY; The requested per database DTU cap. + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + // RequestedDtuGuarantee - READ-ONLY; The requested DTU guarantee. + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolActivityProperties. +func (epap ElasticPoolActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolDatabaseActivity represents the activity on an elastic pool. +type ElasticPoolDatabaseActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolDatabaseActivityProperties - The properties representing the resource. + *ElasticPoolDatabaseActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivity. +func (epda ElasticPoolDatabaseActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epda.Location != nil { + objectMap["location"] = epda.Location + } + if epda.ElasticPoolDatabaseActivityProperties != nil { + objectMap["properties"] = epda.ElasticPoolDatabaseActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolDatabaseActivity struct. +func (epda *ElasticPoolDatabaseActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epda.Location = &location + } + case "properties": + if v != nil { + var elasticPoolDatabaseActivityProperties ElasticPoolDatabaseActivityProperties + err = json.Unmarshal(*v, &elasticPoolDatabaseActivityProperties) + if err != nil { + return err + } + epda.ElasticPoolDatabaseActivityProperties = &elasticPoolDatabaseActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epda.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epda.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epda.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolDatabaseActivityListResult represents the response to a list elastic pool database activity +// request. +type ElasticPoolDatabaseActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool database activities. + Value *[]ElasticPoolDatabaseActivity `json:"value,omitempty"` +} + +// ElasticPoolDatabaseActivityProperties represents the properties of an elastic pool database activity. +type ElasticPoolDatabaseActivityProperties struct { + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The name for the elastic pool the database is moving into if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // CurrentElasticPoolName - READ-ONLY; The name of the current elastic pool the database is in if available. + CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` + // CurrentServiceObjective - READ-ONLY; The name of the current service objective if available. + CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` + // RequestedServiceObjective - READ-ONLY; The name of the requested service objective if available. + RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivityProperties. +func (epdap ElasticPoolDatabaseActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolEditionCapability the elastic pool edition capability. +type ElasticPoolEditionCapability struct { + // Name - READ-ONLY; The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolPerformanceLevels - READ-ONLY; The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolPerformanceLevels *[]ElasticPoolPerformanceLevelCapability `json:"supportedElasticPoolPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolEditionCapability. +func (epec ElasticPoolEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epec.Reason != nil { + objectMap["reason"] = epec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolListResult the result of an elastic pool list request. +type ElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolListResult. +func (eplr ElasticPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolListResultIterator provides access to a complete listing of ElasticPool values. +type ElasticPoolListResultIterator struct { + i int + page ElasticPoolListResultPage +} + +// NextWithContext 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 *ElasticPoolListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolListResultIterator) 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 ElasticPoolListResultIterator) Response() ElasticPoolListResult { + 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 ElasticPoolListResultIterator) Value() ElasticPool { + if !iter.page.NotDone() { + return ElasticPool{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ElasticPoolListResultIterator type. +func NewElasticPoolListResultIterator(page ElasticPoolListResultPage) ElasticPoolListResultIterator { + return ElasticPoolListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr ElasticPoolListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eplr ElasticPoolListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +} + +// elasticPoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr ElasticPoolListResult) elasticPoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// ElasticPoolListResultPage contains a page of ElasticPool values. +type ElasticPoolListResultPage struct { + fn func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error) + eplr ElasticPoolListResult +} + +// NextWithContext 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 *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eplr) + if err != nil { + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolListResultPage) Response() ElasticPoolListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolListResultPage) Values() []ElasticPool { + if page.eplr.IsEmpty() { + return nil + } + return *page.eplr.Value +} + +// Creates a new instance of the ElasticPoolListResultPage type. +func NewElasticPoolListResultPage(cur ElasticPoolListResult, getNextPage func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error)) ElasticPoolListResultPage { + return ElasticPoolListResultPage{ + fn: getNextPage, + eplr: cur, + } +} + +// ElasticPoolOperation a elastic pool operation. +type ElasticPoolOperation struct { + // ElasticPoolOperationProperties - Resource properties. + *ElasticPoolOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperation. +func (epo ElasticPoolOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epo.ElasticPoolOperationProperties != nil { + objectMap["properties"] = epo.ElasticPoolOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolOperation struct. +func (epo *ElasticPoolOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var elasticPoolOperationProperties ElasticPoolOperationProperties + err = json.Unmarshal(*v, &elasticPoolOperationProperties) + if err != nil { + return err + } + epo.ElasticPoolOperationProperties = &elasticPoolOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epo.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epo.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epo.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolOperationListResult the response to a list elastic pool operations request +type ElasticPoolOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPoolOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperationListResult. +func (epolr ElasticPoolOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolOperationListResultIterator provides access to a complete listing of ElasticPoolOperation +// values. +type ElasticPoolOperationListResultIterator struct { + i int + page ElasticPoolOperationListResultPage +} + +// NextWithContext 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 *ElasticPoolOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolOperationListResultIterator) 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 ElasticPoolOperationListResultIterator) Response() ElasticPoolOperationListResult { + 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 ElasticPoolOperationListResultIterator) Value() ElasticPoolOperation { + if !iter.page.NotDone() { + return ElasticPoolOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ElasticPoolOperationListResultIterator type. +func NewElasticPoolOperationListResultIterator(page ElasticPoolOperationListResultPage) ElasticPoolOperationListResultIterator { + return ElasticPoolOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (epolr ElasticPoolOperationListResult) IsEmpty() bool { + return epolr.Value == nil || len(*epolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (epolr ElasticPoolOperationListResult) hasNextLink() bool { + return epolr.NextLink != nil && len(*epolr.NextLink) != 0 +} + +// elasticPoolOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (epolr ElasticPoolOperationListResult) elasticPoolOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !epolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(epolr.NextLink))) +} + +// ElasticPoolOperationListResultPage contains a page of ElasticPoolOperation values. +type ElasticPoolOperationListResultPage struct { + fn func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error) + epolr ElasticPoolOperationListResult +} + +// NextWithContext 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 *ElasticPoolOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.epolr) + if err != nil { + return err + } + page.epolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolOperationListResultPage) NotDone() bool { + return !page.epolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolOperationListResultPage) Response() ElasticPoolOperationListResult { + return page.epolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolOperationListResultPage) Values() []ElasticPoolOperation { + if page.epolr.IsEmpty() { + return nil + } + return *page.epolr.Value +} + +// Creates a new instance of the ElasticPoolOperationListResultPage type. +func NewElasticPoolOperationListResultPage(cur ElasticPoolOperationListResult, getNextPage func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error)) ElasticPoolOperationListResultPage { + return ElasticPoolOperationListResultPage{ + fn: getNextPage, + epolr: cur, + } +} + +// ElasticPoolOperationProperties the properties of a elastic pool operation. +type ElasticPoolOperationProperties struct { + // ElasticPoolName - READ-ONLY; The name of the elastic pool the operation is being performed on. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. + State *string `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperationProperties. +func (epop ElasticPoolOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMaxPerformanceLevelCapability the max per-database performance level capability. +type ElasticPoolPerDatabaseMaxPerformanceLevelCapability struct { + // Limit - READ-ONLY; The maximum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // SupportedPerDatabaseMinPerformanceLevels - READ-ONLY; The list of supported min database performance levels. + SupportedPerDatabaseMinPerformanceLevels *[]ElasticPoolPerDatabaseMinPerformanceLevelCapability `json:"supportedPerDatabaseMinPerformanceLevels,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMaxPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMaxPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMinPerformanceLevelCapability the minimum per-database performance level +// capability. +type ElasticPoolPerDatabaseMinPerformanceLevelCapability struct { + // Limit - READ-ONLY; The minimum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMinPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMinPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseSettings per database settings of an elastic pool. +type ElasticPoolPerDatabaseSettings struct { + // MinCapacity - The minimum capacity all databases are guaranteed. + MinCapacity *float64 `json:"minCapacity,omitempty"` + // MaxCapacity - The maximum capacity any one database can consume. + MaxCapacity *float64 `json:"maxCapacity,omitempty"` +} + +// ElasticPoolPerformanceLevelCapability the Elastic Pool performance level capability. +type ElasticPoolPerformanceLevelCapability struct { + // PerformanceLevel - READ-ONLY; The performance level for the pool. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // MaxDatabaseCount - READ-ONLY; The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size for this performance level. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - READ-ONLY; The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeRangeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxPerformanceLevels - READ-ONLY; The list of supported per database max performance levels. + SupportedPerDatabaseMaxPerformanceLevels *[]ElasticPoolPerDatabaseMaxPerformanceLevelCapability `json:"supportedPerDatabaseMaxPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the performance level. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerformanceLevelCapability. +func (epplc ElasticPoolPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epplc.Reason != nil { + objectMap["reason"] = epplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolProperties properties of an elastic pool +type ElasticPoolProperties struct { + // State - READ-ONLY; The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' + State ElasticPoolState `json:"state,omitempty"` + // CreationDate - READ-ONLY; The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolProperties. +func (epp ElasticPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = epp.MaxSizeBytes + } + if epp.PerDatabaseSettings != nil { + objectMap["perDatabaseSettings"] = epp.PerDatabaseSettings + } + if epp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = epp.ZoneRedundant + } + if epp.LicenseType != "" { + objectMap["licenseType"] = epp.LicenseType + } + return json.Marshal(objectMap) +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsCreateOrUpdateFuture.Result. +func (future *ElasticPoolsCreateOrUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsDeleteFuture.Result. +func (future *ElasticPoolsDeleteFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ElasticPoolsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsFailoverFuture.Result. +func (future *ElasticPoolsFailoverFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsUpdateFuture.Result. +func (future *ElasticPoolsUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.UpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolUpdate an elastic pool update. +type ElasticPoolUpdate struct { + Sku *Sku `json:"sku,omitempty"` + // ElasticPoolUpdateProperties - Resource properties. + *ElasticPoolUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolUpdate. +func (epu ElasticPoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epu.Sku != nil { + objectMap["sku"] = epu.Sku + } + if epu.ElasticPoolUpdateProperties != nil { + objectMap["properties"] = epu.ElasticPoolUpdateProperties + } + if epu.Tags != nil { + objectMap["tags"] = epu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolUpdate struct. +func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + epu.Sku = &sku + } + case "properties": + if v != nil { + var elasticPoolUpdateProperties ElasticPoolUpdateProperties + err = json.Unmarshal(*v, &elasticPoolUpdateProperties) + if err != nil { + return err + } + epu.ElasticPoolUpdateProperties = &elasticPoolUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + epu.Tags = tags + } + } + } + + return nil +} + +// ElasticPoolUpdateProperties properties of an elastic pool +type ElasticPoolUpdateProperties struct { + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` +} + +// EncryptionProtector the server encryption protector. +type EncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // EncryptionProtectorProperties - Resource properties. + *EncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtector. +func (ep EncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.EncryptionProtectorProperties != nil { + objectMap["properties"] = ep.EncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EncryptionProtector struct. +func (ep *EncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "properties": + if v != nil { + var encryptionProtectorProperties EncryptionProtectorProperties + err = json.Unmarshal(*v, &encryptionProtectorProperties) + if err != nil { + return err + } + ep.EncryptionProtectorProperties = &encryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// EncryptionProtectorListResult a list of server encryption protectors. +type EncryptionProtectorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]EncryptionProtector `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtectorListResult. +func (eplr EncryptionProtectorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector +// values. +type EncryptionProtectorListResultIterator struct { + i int + page EncryptionProtectorListResultPage +} + +// NextWithContext 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 *EncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EncryptionProtectorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EncryptionProtectorListResultIterator) 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 EncryptionProtectorListResultIterator) Response() EncryptionProtectorListResult { + 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 EncryptionProtectorListResultIterator) Value() EncryptionProtector { + if !iter.page.NotDone() { + return EncryptionProtector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EncryptionProtectorListResultIterator type. +func NewEncryptionProtectorListResultIterator(page EncryptionProtectorListResultPage) EncryptionProtectorListResultIterator { + return EncryptionProtectorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr EncryptionProtectorListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eplr EncryptionProtectorListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +} + +// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. +type EncryptionProtectorListResultPage struct { + fn func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error) + eplr EncryptionProtectorListResult +} + +// NextWithContext 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 *EncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eplr) + if err != nil { + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *EncryptionProtectorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EncryptionProtectorListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EncryptionProtectorListResultPage) Response() EncryptionProtectorListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EncryptionProtectorListResultPage) Values() []EncryptionProtector { + if page.eplr.IsEmpty() { + return nil + } + return *page.eplr.Value +} + +// Creates a new instance of the EncryptionProtectorListResultPage type. +func NewEncryptionProtectorListResultPage(cur EncryptionProtectorListResult, getNextPage func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error)) EncryptionProtectorListResultPage { + return EncryptionProtectorListResultPage{ + fn: getNextPage, + eplr: cur, + } +} + +// EncryptionProtectorProperties properties for an encryption protector execution. +type EncryptionProtectorProperties struct { + // Subregion - READ-ONLY; Subregion of the encryption protector. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyName - The name of the server key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtectorProperties. +func (epp EncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.ServerKeyName != nil { + objectMap["serverKeyName"] = epp.ServerKeyName + } + if epp.ServerKeyType != "" { + objectMap["serverKeyType"] = epp.ServerKeyType + } + return json.Marshal(objectMap) +} + +// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (EncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *EncryptionProtectorsCreateOrUpdateFuture) result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// EncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsRevalidateFuture.Result. +func (future *EncryptionProtectorsRevalidateFuture) result(client EncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ExportDatabaseDefinition contains the information necessary to perform export database operation. +type ExportDatabaseDefinition struct { + // StorageKeyType - Storage key type. Possible values include: 'SharedAccessKey', 'StorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// ExtendedDatabaseBlobAuditingPolicy an extended database blob auditing policy. +type ExtendedDatabaseBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ExtendedDatabaseBlobAuditingPolicyProperties - Resource properties. + *ExtendedDatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicy. +func (edbap ExtendedDatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if edbap.ExtendedDatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = edbap.ExtendedDatabaseBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExtendedDatabaseBlobAuditingPolicy struct. +func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var extendedDatabaseBlobAuditingPolicyProperties ExtendedDatabaseBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &extendedDatabaseBlobAuditingPolicyProperties) + if err != nil { + return err + } + edbap.ExtendedDatabaseBlobAuditingPolicyProperties = &extendedDatabaseBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + edbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + edbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + edbap.Type = &typeVar + } + } + } + + return nil +} + +// ExtendedDatabaseBlobAuditingPolicyListResult a list of database extended auditing settings. +type ExtendedDatabaseBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ExtendedDatabaseBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicyListResult. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExtendedDatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ExtendedDatabaseBlobAuditingPolicy values. +type ExtendedDatabaseBlobAuditingPolicyListResultIterator struct { + i int + page ExtendedDatabaseBlobAuditingPolicyListResultPage +} + +// NextWithContext 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 *ExtendedDatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) 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 ExtendedDatabaseBlobAuditingPolicyListResultIterator) Response() ExtendedDatabaseBlobAuditingPolicyListResult { + 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 ExtendedDatabaseBlobAuditingPolicyListResultIterator) Value() ExtendedDatabaseBlobAuditingPolicy { + if !iter.page.NotDone() { + return ExtendedDatabaseBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultIterator type. +func NewExtendedDatabaseBlobAuditingPolicyListResultIterator(page ExtendedDatabaseBlobAuditingPolicyListResultPage) ExtendedDatabaseBlobAuditingPolicyListResultIterator { + return ExtendedDatabaseBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) IsEmpty() bool { + return edbaplr.Value == nil || len(*edbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) hasNextLink() bool { + return edbaplr.NextLink != nil && len(*edbaplr.NextLink) != 0 +} + +// extendedDatabaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) extendedDatabaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !edbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(edbaplr.NextLink))) +} + +// ExtendedDatabaseBlobAuditingPolicyListResultPage contains a page of ExtendedDatabaseBlobAuditingPolicy +// values. +type ExtendedDatabaseBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error) + edbaplr ExtendedDatabaseBlobAuditingPolicyListResult +} + +// NextWithContext 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 *ExtendedDatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.edbaplr) + if err != nil { + return err + } + page.edbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.edbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Response() ExtendedDatabaseBlobAuditingPolicyListResult { + return page.edbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Values() []ExtendedDatabaseBlobAuditingPolicy { + if page.edbaplr.IsEmpty() { + return nil + } + return *page.edbaplr.Value +} + +// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultPage type. +func NewExtendedDatabaseBlobAuditingPolicyListResultPage(cur ExtendedDatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error)) ExtendedDatabaseBlobAuditingPolicyListResultPage { + return ExtendedDatabaseBlobAuditingPolicyListResultPage{ + fn: getNextPage, + edbaplr: cur, + } +} + +// ExtendedDatabaseBlobAuditingPolicyProperties properties of an extended database blob auditing policy. +type ExtendedDatabaseBlobAuditingPolicyProperties struct { + // PredicateExpression - Specifies condition of where clause when creating an audit. + PredicateExpression *string `json:"predicateExpression,omitempty"` + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` +} + +// ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ExtendedServerBlobAuditingPoliciesClient) (ExtendedServerBlobAuditingPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture.Result. +func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) result(client ExtendedServerBlobAuditingPoliciesClient) (esbap ExtendedServerBlobAuditingPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + esbap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if esbap.Response.Response, err = future.GetResult(sender); err == nil && esbap.Response.Response.StatusCode != http.StatusNoContent { + esbap, err = client.CreateOrUpdateResponder(esbap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", esbap.Response.Response, "Failure responding to request") + } + } + return +} + +// ExtendedServerBlobAuditingPolicy an extended server blob auditing policy. +type ExtendedServerBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ExtendedServerBlobAuditingPolicyProperties - Resource properties. + *ExtendedServerBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicy. +func (esbap ExtendedServerBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if esbap.ExtendedServerBlobAuditingPolicyProperties != nil { + objectMap["properties"] = esbap.ExtendedServerBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExtendedServerBlobAuditingPolicy struct. +func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var extendedServerBlobAuditingPolicyProperties ExtendedServerBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &extendedServerBlobAuditingPolicyProperties) + if err != nil { + return err + } + esbap.ExtendedServerBlobAuditingPolicyProperties = &extendedServerBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + esbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + esbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + esbap.Type = &typeVar + } + } + } + + return nil +} + +// ExtendedServerBlobAuditingPolicyListResult a list of server extended auditing settings. +type ExtendedServerBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ExtendedServerBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicyListResult. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExtendedServerBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ExtendedServerBlobAuditingPolicy values. +type ExtendedServerBlobAuditingPolicyListResultIterator struct { + i int + page ExtendedServerBlobAuditingPolicyListResultPage +} + +// NextWithContext 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 *ExtendedServerBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) 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 ExtendedServerBlobAuditingPolicyListResultIterator) Response() ExtendedServerBlobAuditingPolicyListResult { + 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 ExtendedServerBlobAuditingPolicyListResultIterator) Value() ExtendedServerBlobAuditingPolicy { + if !iter.page.NotDone() { + return ExtendedServerBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultIterator type. +func NewExtendedServerBlobAuditingPolicyListResultIterator(page ExtendedServerBlobAuditingPolicyListResultPage) ExtendedServerBlobAuditingPolicyListResultIterator { + return ExtendedServerBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) IsEmpty() bool { + return esbaplr.Value == nil || len(*esbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) hasNextLink() bool { + return esbaplr.NextLink != nil && len(*esbaplr.NextLink) != 0 +} + +// extendedServerBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) extendedServerBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !esbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(esbaplr.NextLink))) +} + +// ExtendedServerBlobAuditingPolicyListResultPage contains a page of ExtendedServerBlobAuditingPolicy +// values. +type ExtendedServerBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error) + esbaplr ExtendedServerBlobAuditingPolicyListResult +} + +// NextWithContext 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 *ExtendedServerBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.esbaplr) + if err != nil { + return err + } + page.esbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ExtendedServerBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExtendedServerBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.esbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExtendedServerBlobAuditingPolicyListResultPage) Response() ExtendedServerBlobAuditingPolicyListResult { + return page.esbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExtendedServerBlobAuditingPolicyListResultPage) Values() []ExtendedServerBlobAuditingPolicy { + if page.esbaplr.IsEmpty() { + return nil + } + return *page.esbaplr.Value +} + +// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultPage type. +func NewExtendedServerBlobAuditingPolicyListResultPage(cur ExtendedServerBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error)) ExtendedServerBlobAuditingPolicyListResultPage { + return ExtendedServerBlobAuditingPolicyListResultPage{ + fn: getNextPage, + esbaplr: cur, + } +} + +// ExtendedServerBlobAuditingPolicyProperties properties of an extended server blob auditing policy. +type ExtendedServerBlobAuditingPolicyProperties struct { + // PredicateExpression - Specifies condition of where clause when creating an audit. + PredicateExpression *string `json:"predicateExpression,omitempty"` + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` +} + +// FailoverGroup a failover group. +type FailoverGroup struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // FailoverGroupProperties - Resource properties. + *FailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroup. +func (fg FailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fg.Tags != nil { + objectMap["tags"] = fg.Tags + } + if fg.FailoverGroupProperties != nil { + objectMap["properties"] = fg.FailoverGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroup struct. +func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fg.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fg.Tags = tags + } + case "properties": + if v != nil { + var failoverGroupProperties FailoverGroupProperties + err = json.Unmarshal(*v, &failoverGroupProperties) + if err != nil { + return err + } + fg.FailoverGroupProperties = &failoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fg.Type = &typeVar + } + } + } + + return nil +} + +// FailoverGroupListResult a list of failover groups. +type FailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]FailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupListResult. +func (fglr FailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. +type FailoverGroupListResultIterator struct { + i int + page FailoverGroupListResultPage +} + +// NextWithContext 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 *FailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *FailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FailoverGroupListResultIterator) 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 FailoverGroupListResultIterator) Response() FailoverGroupListResult { + 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 FailoverGroupListResultIterator) Value() FailoverGroup { + if !iter.page.NotDone() { + return FailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FailoverGroupListResultIterator type. +func NewFailoverGroupListResultIterator(page FailoverGroupListResultPage) FailoverGroupListResultIterator { + return FailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (fglr FailoverGroupListResult) IsEmpty() bool { + return fglr.Value == nil || len(*fglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (fglr FailoverGroupListResult) hasNextLink() bool { + return fglr.NextLink != nil && len(*fglr.NextLink) != 0 +} + +// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (fglr FailoverGroupListResult) failoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !fglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(fglr.NextLink))) +} + +// FailoverGroupListResultPage contains a page of FailoverGroup values. +type FailoverGroupListResultPage struct { + fn func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error) + fglr FailoverGroupListResult +} + +// NextWithContext 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 *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.fglr) + if err != nil { + return err + } + page.fglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *FailoverGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FailoverGroupListResultPage) NotDone() bool { + return !page.fglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FailoverGroupListResultPage) Response() FailoverGroupListResult { + return page.fglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FailoverGroupListResultPage) Values() []FailoverGroup { + if page.fglr.IsEmpty() { + return nil + } + return *page.fglr.Value +} + +// Creates a new instance of the FailoverGroupListResultPage type. +func NewFailoverGroupListResultPage(cur FailoverGroupListResult, getNextPage func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error)) FailoverGroupListResultPage { + return FailoverGroupListResultPage{ + fn: getNextPage, + fglr: cur, + } +} + +// FailoverGroupProperties properties of a failover group. +type FailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerServers - List of partner server information for the failover group. + PartnerServers *[]PartnerInfo `json:"partnerServers,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupProperties. +func (fgp FailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = fgp.ReadWriteEndpoint + } + if fgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = fgp.ReadOnlyEndpoint + } + if fgp.PartnerServers != nil { + objectMap["partnerServers"] = fgp.PartnerServers + } + if fgp.Databases != nil { + objectMap["databases"] = fgp.Databases + } + return json.Marshal(objectMap) +} + +// FailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type FailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// FailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type FailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'Manual', 'Automatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// FailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsCreateOrUpdateFuture.Result. +func (future *FailoverGroupsCreateOrUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.CreateOrUpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsDeleteFuture.Result. +func (future *FailoverGroupsDeleteFuture) result(client FailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsFailoverFuture.Result. +func (future *FailoverGroupsFailoverFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.FailoverResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type FailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.ForceFailoverAllowDataLossResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsUpdateFuture.Result. +func (future *FailoverGroupsUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.UpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupUpdate a failover group update request. +type FailoverGroupUpdate struct { + // FailoverGroupUpdateProperties - Resource properties. + *FailoverGroupUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupUpdate. +func (fgu FailoverGroupUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgu.FailoverGroupUpdateProperties != nil { + objectMap["properties"] = fgu.FailoverGroupUpdateProperties + } + if fgu.Tags != nil { + objectMap["tags"] = fgu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroupUpdate struct. +func (fgu *FailoverGroupUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var failoverGroupUpdateProperties FailoverGroupUpdateProperties + err = json.Unmarshal(*v, &failoverGroupUpdateProperties) + if err != nil { + return err + } + fgu.FailoverGroupUpdateProperties = &failoverGroupUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fgu.Tags = tags + } + } + } + + return nil +} + +// FailoverGroupUpdateProperties properties of a failover group update. +type FailoverGroupUpdateProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// FirewallRule represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of server that contains this firewall rule. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Location of the server that contains this firewall rule. + Location *string `json:"location,omitempty"` + // FirewallRuleProperties - The properties representing the resource. + *FirewallRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + fr.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fr.Location = &location + } + case "properties": + if v != nil { + var firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fr.Type = &typeVar + } + } + } + + return nil +} + +// FirewallRuleListResult represents the response to a List Firewall Rules request. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of server firewall rules. + Value *[]FirewallRule `json:"value,omitempty"` +} + +// FirewallRuleProperties represents the properties of a server firewall rule. +type FirewallRuleProperties struct { + // StartIPAddress - The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' to represent all Azure-internal IP addresses. + StartIPAddress *string `json:"startIpAddress,omitempty"` + // EndIPAddress - The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. Use value '0.0.0.0' to represent all Azure-internal IP addresses. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// GeoBackupPolicy a database geo backup policy. +type GeoBackupPolicy struct { + autorest.Response `json:"-"` + // GeoBackupPolicyProperties - The properties of the geo backup policy. + *GeoBackupPolicyProperties `json:"properties,omitempty"` + // Kind - READ-ONLY; Kind of geo backup policy. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Backup policy location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GeoBackupPolicy. +func (gbp GeoBackupPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbp.GeoBackupPolicyProperties != nil { + objectMap["properties"] = gbp.GeoBackupPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GeoBackupPolicy struct. +func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var geoBackupPolicyProperties GeoBackupPolicyProperties + err = json.Unmarshal(*v, &geoBackupPolicyProperties) + if err != nil { + return err + } + gbp.GeoBackupPolicyProperties = &geoBackupPolicyProperties + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + gbp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gbp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gbp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gbp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gbp.Type = &typeVar + } + } + } + + return nil +} + +// GeoBackupPolicyListResult the response to a list geo backup policies request. +type GeoBackupPolicyListResult struct { + autorest.Response `json:"-"` + // Value - The list of geo backup policies. + Value *[]GeoBackupPolicy `json:"value,omitempty"` +} + +// GeoBackupPolicyProperties the properties of the geo backup policy. +type GeoBackupPolicyProperties struct { + // State - The state of the geo backup policy. Possible values include: 'GeoBackupPolicyStateDisabled', 'GeoBackupPolicyStateEnabled' + State GeoBackupPolicyState `json:"state,omitempty"` + // StorageType - READ-ONLY; The storage type of the geo backup policy. + StorageType *string `json:"storageType,omitempty"` +} + +// MarshalJSON is the custom marshaler for GeoBackupPolicyProperties. +func (gbpp GeoBackupPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbpp.State != "" { + objectMap["state"] = gbpp.State + } + return json.Marshal(objectMap) +} + +// ImportExistingDatabaseDefinition contains the information necessary to perform import operation for +// existing database. +type ImportExistingDatabaseDefinition struct { + // StorageKeyType - Storage key type. Possible values include: 'SharedAccessKey', 'StorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// ImportExportImportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ImportExportImportFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ImportExportClient) (ImportExportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ImportExportImportFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ImportExportImportFuture.Result. +func (future *ImportExportImportFuture) result(client ImportExportClient) (ieor ImportExportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ImportExportImportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ImportExportImportFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ImportResponder(ieor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ImportExportImportFuture", "Result", ieor.Response.Response, "Failure responding to request") + } + } + return +} + +// ImportExportOperationResult an ImportExport operation result resource. +type ImportExportOperationResult struct { + autorest.Response `json:"-"` + // ImportExportOperationResultProperties - Resource properties. + *ImportExportOperationResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportOperationResult. +func (ieor ImportExportOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ieor.ImportExportOperationResultProperties != nil { + objectMap["properties"] = ieor.ImportExportOperationResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ImportExportOperationResult struct. +func (ieor *ImportExportOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var importExportOperationResultProperties ImportExportOperationResultProperties + err = json.Unmarshal(*v, &importExportOperationResultProperties) + if err != nil { + return err + } + ieor.ImportExportOperationResultProperties = &importExportOperationResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ieor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ieor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ieor.Type = &typeVar + } + } + } + + return nil +} + +// ImportExportOperationResultProperties contains the operation result properties for import/export +// operation. +type ImportExportOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // RequestType - READ-ONLY; Request type. + RequestType *string `json:"requestType,omitempty"` + // QueuedTime - READ-ONLY; Queued time. + QueuedTime *string `json:"queuedTime,omitempty"` + // LastModifiedTime - READ-ONLY; Last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // BlobURI - READ-ONLY; Blob Uri. + BlobURI *string `json:"blobUri,omitempty"` + // ServerName - READ-ONLY; Server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - READ-ONLY; Operation status. + Status *string `json:"status,omitempty"` + // ErrorMessage - READ-ONLY; Error message. + ErrorMessage *string `json:"errorMessage,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Gets the status of private endpoints associated with this request. + PrivateEndpointConnections *[]PrivateEndpointConnectionRequestStatus `json:"privateEndpointConnections,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportOperationResultProperties. +func (ieorp ImportExportOperationResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ImportNewDatabaseDefinition contains the information necessary to perform import operation for new +// database. +type ImportNewDatabaseDefinition struct { + // DatabaseName - Name of the import database. + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - Edition of the import database. + Edition *string `json:"edition,omitempty"` + // ServiceObjectiveName - Service level objective name of the import database. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // MaxSizeBytes - Max size in bytes for the import database. + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // StorageKeyType - Storage key type. Possible values include: 'SharedAccessKey', 'StorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// InstanceFailoverGroup an instance failover group. +type InstanceFailoverGroup struct { + autorest.Response `json:"-"` + // InstanceFailoverGroupProperties - Resource properties. + *InstanceFailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroup. +func (ifg InstanceFailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifg.InstanceFailoverGroupProperties != nil { + objectMap["properties"] = ifg.InstanceFailoverGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InstanceFailoverGroup struct. +func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var instanceFailoverGroupProperties InstanceFailoverGroupProperties + err = json.Unmarshal(*v, &instanceFailoverGroupProperties) + if err != nil { + return err + } + ifg.InstanceFailoverGroupProperties = &instanceFailoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ifg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ifg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ifg.Type = &typeVar + } + } + } + + return nil +} + +// InstanceFailoverGroupListResult a list of instance failover groups. +type InstanceFailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstanceFailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupListResult. +func (ifglr InstanceFailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup +// values. +type InstanceFailoverGroupListResultIterator struct { + i int + page InstanceFailoverGroupListResultPage +} + +// NextWithContext 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 *InstanceFailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstanceFailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstanceFailoverGroupListResultIterator) 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 InstanceFailoverGroupListResultIterator) Response() InstanceFailoverGroupListResult { + 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 InstanceFailoverGroupListResultIterator) Value() InstanceFailoverGroup { + if !iter.page.NotDone() { + return InstanceFailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstanceFailoverGroupListResultIterator type. +func NewInstanceFailoverGroupListResultIterator(page InstanceFailoverGroupListResultPage) InstanceFailoverGroupListResultIterator { + return InstanceFailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { + return ifglr.Value == nil || len(*ifglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ifglr InstanceFailoverGroupListResult) hasNextLink() bool { + return ifglr.NextLink != nil && len(*ifglr.NextLink) != 0 +} + +// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ifglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ifglr.NextLink))) +} + +// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultPage struct { + fn func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) + ifglr InstanceFailoverGroupListResult +} + +// NextWithContext 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 *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ifglr) + if err != nil { + return err + } + page.ifglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *InstanceFailoverGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InstanceFailoverGroupListResultPage) NotDone() bool { + return !page.ifglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InstanceFailoverGroupListResultPage) Response() InstanceFailoverGroupListResult { + return page.ifglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InstanceFailoverGroupListResultPage) Values() []InstanceFailoverGroup { + if page.ifglr.IsEmpty() { + return nil + } + return *page.ifglr.Value +} + +// Creates a new instance of the InstanceFailoverGroupListResultPage type. +func NewInstanceFailoverGroupListResultPage(cur InstanceFailoverGroupListResult, getNextPage func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error)) InstanceFailoverGroupListResultPage { + return InstanceFailoverGroupListResultPage{ + fn: getNextPage, + ifglr: cur, + } +} + +// InstanceFailoverGroupProperties properties of a instance failover group. +type InstanceFailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *InstanceFailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *InstanceFailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'InstanceFailoverGroupReplicationRolePrimary', 'InstanceFailoverGroupReplicationRoleSecondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerRegions - Partner region information for the failover group. + PartnerRegions *[]PartnerRegionInfo `json:"partnerRegions,omitempty"` + // ManagedInstancePairs - List of managed instance pairs in the failover group. + ManagedInstancePairs *[]ManagedInstancePairInfo `json:"managedInstancePairs,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupProperties. +func (ifgp InstanceFailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = ifgp.ReadWriteEndpoint + } + if ifgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = ifgp.ReadOnlyEndpoint + } + if ifgp.PartnerRegions != nil { + objectMap["partnerRegions"] = ifgp.PartnerRegions + } + if ifgp.ManagedInstancePairs != nil { + objectMap["managedInstancePairs"] = ifgp.ManagedInstancePairs + } + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type InstanceFailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// InstanceFailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type InstanceFailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'Manual', 'Automatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// InstanceFailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsCreateOrUpdateFuture.Result. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.CreateOrUpdateResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsDeleteFuture.Result. +func (future *InstanceFailoverGroupsDeleteFuture) result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsFailoverFuture.Result. +func (future *InstanceFailoverGroupsFailoverFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.FailoverResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.ForceFailoverAllowDataLossResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstancePool an Azure SQL instance pool. +type InstancePool struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // InstancePoolProperties - Resource properties. + *InstancePoolProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePool. +func (IP InstancePool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if IP.Sku != nil { + objectMap["sku"] = IP.Sku + } + if IP.InstancePoolProperties != nil { + objectMap["properties"] = IP.InstancePoolProperties + } + if IP.Location != nil { + objectMap["location"] = IP.Location + } + if IP.Tags != nil { + objectMap["tags"] = IP.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InstancePool struct. +func (IP *InstancePool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + IP.Sku = &sku + } + case "properties": + if v != nil { + var instancePoolProperties InstancePoolProperties + err = json.Unmarshal(*v, &instancePoolProperties) + if err != nil { + return err + } + IP.InstancePoolProperties = &instancePoolProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + IP.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + IP.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + IP.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + IP.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + IP.Type = &typeVar + } + } + } + + return nil +} + +// InstancePoolEditionCapability the instance pool capability +type InstancePoolEditionCapability struct { + // Name - READ-ONLY; The instance pool version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]InstancePoolFamilyCapability `json:"supportedFamilies,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolEditionCapability. +func (ipec InstancePoolEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipec.Reason != nil { + objectMap["reason"] = ipec.Reason + } + return json.Marshal(objectMap) +} + +// InstancePoolFamilyCapability the instance pool family capability. +type InstancePoolFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]InstancePoolVcoresCapability `json:"supportedVcoresValues,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolFamilyCapability. +func (ipfc InstancePoolFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipfc.Reason != nil { + objectMap["reason"] = ipfc.Reason + } + return json.Marshal(objectMap) +} + +// InstancePoolListResult a list of Azure SQL instance pools. +type InstancePoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstancePool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolListResult. +func (iplr InstancePoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstancePoolListResultIterator provides access to a complete listing of InstancePool values. +type InstancePoolListResultIterator struct { + i int + page InstancePoolListResultPage +} + +// NextWithContext 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 *InstancePoolListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstancePoolListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstancePoolListResultIterator) 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 InstancePoolListResultIterator) Response() InstancePoolListResult { + 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 InstancePoolListResultIterator) Value() InstancePool { + if !iter.page.NotDone() { + return InstancePool{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstancePoolListResultIterator type. +func NewInstancePoolListResultIterator(page InstancePoolListResultPage) InstancePoolListResultIterator { + return InstancePoolListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (iplr InstancePoolListResult) IsEmpty() bool { + return iplr.Value == nil || len(*iplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (iplr InstancePoolListResult) hasNextLink() bool { + return iplr.NextLink != nil && len(*iplr.NextLink) != 0 +} + +// instancePoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (iplr InstancePoolListResult) instancePoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !iplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(iplr.NextLink))) +} + +// InstancePoolListResultPage contains a page of InstancePool values. +type InstancePoolListResultPage struct { + fn func(context.Context, InstancePoolListResult) (InstancePoolListResult, error) + iplr InstancePoolListResult +} + +// NextWithContext 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 *InstancePoolListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.iplr) + if err != nil { + return err + } + page.iplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *InstancePoolListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InstancePoolListResultPage) NotDone() bool { + return !page.iplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InstancePoolListResultPage) Response() InstancePoolListResult { + return page.iplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InstancePoolListResultPage) Values() []InstancePool { + if page.iplr.IsEmpty() { + return nil + } + return *page.iplr.Value +} + +// Creates a new instance of the InstancePoolListResultPage type. +func NewInstancePoolListResultPage(cur InstancePoolListResult, getNextPage func(context.Context, InstancePoolListResult) (InstancePoolListResult, error)) InstancePoolListResultPage { + return InstancePoolListResultPage{ + fn: getNextPage, + iplr: cur, + } +} + +// InstancePoolProperties properties of an instance pool. +type InstancePoolProperties struct { + // SubnetID - Resource ID of the subnet to place this instance pool in. + SubnetID *string `json:"subnetId,omitempty"` + // VCores - Count of vCores belonging to this instance pool. + VCores *int32 `json:"vCores,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and 'BasePrice' (without SQL license price). Possible values include: 'InstancePoolLicenseTypeLicenseIncluded', 'InstancePoolLicenseTypeBasePrice' + LicenseType InstancePoolLicenseType `json:"licenseType,omitempty"` +} + +// InstancePoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstancePoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstancePoolsClient) (InstancePool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstancePoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstancePoolsCreateOrUpdateFuture.Result. +func (future *InstancePoolsCreateOrUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + IP.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { + IP, err = client.CreateOrUpdateResponder(IP.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") + } + } + return +} + +// InstancePoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstancePoolsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstancePoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstancePoolsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstancePoolsDeleteFuture.Result. +func (future *InstancePoolsDeleteFuture) result(client InstancePoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// InstancePoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstancePoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstancePoolsClient) (InstancePool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstancePoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstancePoolsUpdateFuture.Result. +func (future *InstancePoolsUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + IP.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { + IP, err = client.UpdateResponder(IP.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") + } + } + return +} + +// InstancePoolUpdate an update to an Instance pool. +type InstancePoolUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for InstancePoolUpdate. +func (ipu InstancePoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipu.Tags != nil { + objectMap["tags"] = ipu.Tags + } + return json.Marshal(objectMap) +} + +// InstancePoolVcoresCapability the managed instance virtual cores capability. +type InstancePoolVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // StorageLimit - READ-ONLY; Storage limit. + StorageLimit *MaxSizeCapability `json:"storageLimit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolVcoresCapability. +func (ipvc InstancePoolVcoresCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipvc.Reason != nil { + objectMap["reason"] = ipvc.Reason + } + return json.Marshal(objectMap) +} + +// Job a job. +type Job struct { + autorest.Response `json:"-"` + // JobProperties - Resource properties. + *JobProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Job. +func (j Job) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if j.JobProperties != nil { + objectMap["properties"] = j.JobProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobProperties JobProperties + err = json.Unmarshal(*v, &jobProperties) + if err != nil { + return err + } + j.JobProperties = &jobProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + j.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + j.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + j.Type = &typeVar + } + } + } + + return nil +} + +// JobAgent an Azure SQL job agent. +type JobAgent struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // JobAgentProperties - Resource properties. + *JobAgentProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgent. +func (ja JobAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ja.Sku != nil { + objectMap["sku"] = ja.Sku + } + if ja.JobAgentProperties != nil { + objectMap["properties"] = ja.JobAgentProperties + } + if ja.Location != nil { + objectMap["location"] = ja.Location + } + if ja.Tags != nil { + objectMap["tags"] = ja.Tags + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ja.Sku = &sku + } + case "properties": + if v != nil { + var jobAgentProperties JobAgentProperties + err = json.Unmarshal(*v, &jobAgentProperties) + if err != nil { + return err + } + ja.JobAgentProperties = &jobAgentProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ja.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ja.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ja.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ja.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &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 - READ-ONLY; Array of results. + Value *[]JobAgent `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgentListResult. +func (jalr JobAgentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobAgentListResultIterator provides access to a complete listing of JobAgent values. +type JobAgentListResultIterator struct { + i int + page JobAgentListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobAgentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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] +} + +// Creates a new instance of the JobAgentListResultIterator type. +func NewJobAgentListResultIterator(page JobAgentListResultPage) JobAgentListResultIterator { + return JobAgentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jalr JobAgentListResult) IsEmpty() bool { + return jalr.Value == nil || len(*jalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jalr JobAgentListResult) hasNextLink() bool { + return jalr.NextLink != nil && len(*jalr.NextLink) != 0 +} + +// jobAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jalr JobAgentListResult) jobAgentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jalr.NextLink))) +} + +// JobAgentListResultPage contains a page of JobAgent values. +type JobAgentListResultPage struct { + fn func(context.Context, JobAgentListResult) (JobAgentListResult, error) + jalr JobAgentListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jalr) + if err != nil { + return err + } + page.jalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobAgentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobAgentListResultPage type. +func NewJobAgentListResultPage(cur JobAgentListResult, getNextPage func(context.Context, JobAgentListResult) (JobAgentListResult, error)) JobAgentListResultPage { + return JobAgentListResultPage{ + fn: getNextPage, + jalr: cur, + } +} + +// 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"` + // State - READ-ONLY; The state of the job agent. Possible values include: 'JobAgentStateCreating', 'JobAgentStateReady', 'JobAgentStateUpdating', 'JobAgentStateDeleting', 'JobAgentStateDisabled' + State JobAgentState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgentProperties. +func (jap JobAgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jap.DatabaseID != nil { + objectMap["databaseId"] = jap.DatabaseID + } + return json.Marshal(objectMap) +} + +// JobAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (JobAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsCreateOrUpdateFuture.Result. +func (future *JobAgentsCreateOrUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ja.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { + ja, err = client.CreateOrUpdateResponder(ja.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") + } + } + return +} + +// JobAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsDeleteFuture.Result. +func (future *JobAgentsDeleteFuture) result(client JobAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// JobAgentsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (JobAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsUpdateFuture.Result. +func (future *JobAgentsUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ja.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { + ja, err = client.UpdateResponder(ja.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", ja.Response.Response, "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"` +} + +// MarshalJSON is the custom marshaler for JobAgentUpdate. +func (jau JobAgentUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jau.Tags != nil { + objectMap["tags"] = jau.Tags + } + return json.Marshal(objectMap) +} + +// JobCredential a stored credential that can be used by a job to connect to target databases. +type JobCredential struct { + autorest.Response `json:"-"` + // JobCredentialProperties - Resource properties. + *JobCredentialProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCredential. +func (jc JobCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jc.JobCredentialProperties != nil { + objectMap["properties"] = jc.JobCredentialProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCredentialProperties JobCredentialProperties + err = json.Unmarshal(*v, &jobCredentialProperties) + if err != nil { + return err + } + jc.JobCredentialProperties = &jobCredentialProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jc.Type = &typeVar + } + } + } + + return nil +} + +// JobCredentialListResult a list of job credentials. +type JobCredentialListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobCredential `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCredentialListResult. +func (jclr JobCredentialListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobCredentialListResultIterator provides access to a complete listing of JobCredential values. +type JobCredentialListResultIterator struct { + i int + page JobCredentialListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobCredentialListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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] +} + +// Creates a new instance of the JobCredentialListResultIterator type. +func NewJobCredentialListResultIterator(page JobCredentialListResultPage) JobCredentialListResultIterator { + return JobCredentialListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jclr JobCredentialListResult) IsEmpty() bool { + return jclr.Value == nil || len(*jclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jclr JobCredentialListResult) hasNextLink() bool { + return jclr.NextLink != nil && len(*jclr.NextLink) != 0 +} + +// jobCredentialListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jclr JobCredentialListResult) jobCredentialListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jclr.NextLink))) +} + +// JobCredentialListResultPage contains a page of JobCredential values. +type JobCredentialListResultPage struct { + fn func(context.Context, JobCredentialListResult) (JobCredentialListResult, error) + jclr JobCredentialListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jclr) + if err != nil { + return err + } + page.jclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobCredentialListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobCredentialListResultPage type. +func NewJobCredentialListResultPage(cur JobCredentialListResult, getNextPage func(context.Context, JobCredentialListResult) (JobCredentialListResult, error)) JobCredentialListResultPage { + return JobCredentialListResultPage{ + fn: getNextPage, + jclr: cur, + } +} + +// 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:"-"` + // JobExecutionProperties - Resource properties. + *JobExecutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecution. +func (je JobExecution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if je.JobExecutionProperties != nil { + objectMap["properties"] = je.JobExecutionProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobExecutionProperties JobExecutionProperties + err = json.Unmarshal(*v, &jobExecutionProperties) + if err != nil { + return err + } + je.JobExecutionProperties = &jobExecutionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + je.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + je.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + je.Type = &typeVar + } + } + } + + return nil +} + +// JobExecutionListResult a list of job executions. +type JobExecutionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobExecution `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionListResult. +func (jelr JobExecutionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobExecutionListResultIterator provides access to a complete listing of JobExecution values. +type JobExecutionListResultIterator struct { + i int + page JobExecutionListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobExecutionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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] +} + +// Creates a new instance of the JobExecutionListResultIterator type. +func NewJobExecutionListResultIterator(page JobExecutionListResultPage) JobExecutionListResultIterator { + return JobExecutionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jelr JobExecutionListResult) IsEmpty() bool { + return jelr.Value == nil || len(*jelr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jelr JobExecutionListResult) hasNextLink() bool { + return jelr.NextLink != nil && len(*jelr.NextLink) != 0 +} + +// jobExecutionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jelr JobExecutionListResult) jobExecutionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jelr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jelr.NextLink))) +} + +// JobExecutionListResultPage contains a page of JobExecution values. +type JobExecutionListResultPage struct { + fn func(context.Context, JobExecutionListResult) (JobExecutionListResult, error) + jelr JobExecutionListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jelr) + if err != nil { + return err + } + page.jelr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobExecutionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobExecutionListResultPage type. +func NewJobExecutionListResultPage(cur JobExecutionListResult, getNextPage func(context.Context, JobExecutionListResult) (JobExecutionListResult, error)) JobExecutionListResultPage { + return JobExecutionListResultPage{ + fn: getNextPage, + jelr: cur, + } +} + +// JobExecutionProperties properties for an Azure SQL Database Elastic job execution. +type JobExecutionProperties struct { + // JobVersion - READ-ONLY; The job version number. + JobVersion *int32 `json:"jobVersion,omitempty"` + // StepName - READ-ONLY; The job step name. + StepName *string `json:"stepName,omitempty"` + // StepID - READ-ONLY; The job step id. + StepID *int32 `json:"stepId,omitempty"` + // JobExecutionID - READ-ONLY; The unique identifier of the job execution. + JobExecutionID *uuid.UUID `json:"jobExecutionId,omitempty"` + // Lifecycle - READ-ONLY; 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 - READ-ONLY; The ARM provisioning state of the job execution. Possible values include: 'ProvisioningStateCreated', 'ProvisioningStateInProgress', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // CreateTime - READ-ONLY; The time that the job execution was created. + CreateTime *date.Time `json:"createTime,omitempty"` + // StartTime - READ-ONLY; The time that the job execution started. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; 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 - READ-ONLY; Start time of the current attempt. + CurrentAttemptStartTime *date.Time `json:"currentAttemptStartTime,omitempty"` + // LastMessage - READ-ONLY; The last status or error message. + LastMessage *string `json:"lastMessage,omitempty"` + // Target - READ-ONLY; The target that this execution is executed on. + Target *JobExecutionTarget `json:"target,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionProperties. +func (jep JobExecutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jep.CurrentAttempts != nil { + objectMap["currentAttempts"] = jep.CurrentAttempts + } + return json.Marshal(objectMap) +} + +// JobExecutionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobExecutionsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobExecutionsClient) (JobExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobExecutionsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobExecutionsCreateFuture.Result. +func (future *JobExecutionsCreateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + je.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { + je, err = client.CreateResponder(je.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", je.Response.Response, "Failure responding to request") + } + } + return +} + +// JobExecutionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type JobExecutionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobExecutionsClient) (JobExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobExecutionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobExecutionsCreateOrUpdateFuture.Result. +func (future *JobExecutionsCreateOrUpdateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + je.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { + je, err = client.CreateOrUpdateResponder(je.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", je.Response.Response, "Failure responding to request") + } + } + return +} + +// JobExecutionTarget the target that a job execution is executed on. +type JobExecutionTarget struct { + // Type - READ-ONLY; The type of the target. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' + Type JobTargetType `json:"type,omitempty"` + // ServerName - READ-ONLY; The server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionTarget. +func (jet JobExecutionTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobListResult a list of jobs. +type JobListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Job `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobListResult. +func (jlr JobListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobListResultIterator provides access to a complete listing of Job values. +type JobListResultIterator struct { + i int + page JobListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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] +} + +// Creates a new instance of the JobListResultIterator type. +func NewJobListResultIterator(page JobListResultPage) JobListResultIterator { + return JobListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jlr JobListResult) IsEmpty() bool { + return jlr.Value == nil || len(*jlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jlr JobListResult) hasNextLink() bool { + return jlr.NextLink != nil && len(*jlr.NextLink) != 0 +} + +// jobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jlr JobListResult) jobListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jlr.NextLink))) +} + +// JobListResultPage contains a page of Job values. +type JobListResultPage struct { + fn func(context.Context, JobListResult) (JobListResult, error) + jlr JobListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jlr) + if err != nil { + return err + } + page.jlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobListResultPage type. +func NewJobListResultPage(cur JobListResult, getNextPage func(context.Context, JobListResult) (JobListResult, error)) JobListResultPage { + return JobListResultPage{ + fn: getNextPage, + jlr: cur, + } +} + +// JobProperties properties of a job. +type JobProperties struct { + // Description - User-defined description of the job. + Description *string `json:"description,omitempty"` + // Version - READ-ONLY; The job version number. + Version *int32 `json:"version,omitempty"` + // Schedule - Schedule properties of the job. + Schedule *JobSchedule `json:"schedule,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobProperties. +func (jp JobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jp.Description != nil { + objectMap["description"] = jp.Description + } + if jp.Schedule != nil { + objectMap["schedule"] = jp.Schedule + } + return json.Marshal(objectMap) +} + +// 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 schedule type is recurring. ISO8601 duration format. + Interval *string `json:"interval,omitempty"` +} + +// JobStep a job step. +type JobStep struct { + autorest.Response `json:"-"` + // JobStepProperties - Resource properties. + *JobStepProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStep. +func (js JobStep) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if js.JobStepProperties != nil { + objectMap["properties"] = js.JobStepProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobStepProperties JobStepProperties + err = json.Unmarshal(*v, &jobStepProperties) + if err != nil { + return err + } + js.JobStepProperties = &jobStepProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + js.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &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 - READ-ONLY; Array of results. + Value *[]JobStep `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStepListResult. +func (jslr JobStepListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobStepListResultIterator provides access to a complete listing of JobStep values. +type JobStepListResultIterator struct { + i int + page JobStepListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobStepListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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] +} + +// Creates a new instance of the JobStepListResultIterator type. +func NewJobStepListResultIterator(page JobStepListResultPage) JobStepListResultIterator { + return JobStepListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobStepListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jslr JobStepListResult) hasNextLink() bool { + return jslr.NextLink != nil && len(*jslr.NextLink) != 0 +} + +// jobStepListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobStepListResult) jobStepListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobStepListResultPage contains a page of JobStep values. +type JobStepListResultPage struct { + fn func(context.Context, JobStepListResult) (JobStepListResult, error) + jslr JobStepListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jslr) + if err != nil { + return err + } + page.jslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobStepListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobStepListResultPage type. +func NewJobStepListResultPage(cur JobStepListResult, getNextPage func(context.Context, JobStepListResult) (JobStepListResult, error)) JobStepListResultPage { + return JobStepListResultPage{ + fn: getNextPage, + jslr: cur, + } +} + +// 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"` + // ResourceGroupName - The output destination resource group. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ServerName - The output destination server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The output destination database. + DatabaseName *string `json:"databaseName,omitempty"` + // SchemaName - The output destination schema. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - The output destination table. + TableName *string `json:"tableName,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:"-"` + // JobTargetGroupProperties - Resource properties. + *JobTargetGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobTargetGroup. +func (jtg JobTargetGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jtg.JobTargetGroupProperties != nil { + objectMap["properties"] = jtg.JobTargetGroupProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobTargetGroupProperties JobTargetGroupProperties + err = json.Unmarshal(*v, &jobTargetGroupProperties) + if err != nil { + return err + } + jtg.JobTargetGroupProperties = &jobTargetGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jtg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jtg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jtg.Type = &typeVar + } + } + } + + return nil +} + +// JobTargetGroupListResult a list of target groups. +type JobTargetGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobTargetGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobTargetGroupListResult. +func (jtglr JobTargetGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobTargetGroupListResultIterator provides access to a complete listing of JobTargetGroup values. +type JobTargetGroupListResultIterator struct { + i int + page JobTargetGroupListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobTargetGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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] +} + +// Creates a new instance of the JobTargetGroupListResultIterator type. +func NewJobTargetGroupListResultIterator(page JobTargetGroupListResultPage) JobTargetGroupListResultIterator { + return JobTargetGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jtglr JobTargetGroupListResult) IsEmpty() bool { + return jtglr.Value == nil || len(*jtglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jtglr JobTargetGroupListResult) hasNextLink() bool { + return jtglr.NextLink != nil && len(*jtglr.NextLink) != 0 +} + +// jobTargetGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jtglr JobTargetGroupListResult) jobTargetGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jtglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jtglr.NextLink))) +} + +// JobTargetGroupListResultPage contains a page of JobTargetGroup values. +type JobTargetGroupListResultPage struct { + fn func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error) + jtglr JobTargetGroupListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jtglr) + if err != nil { + return err + } + page.jtglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobTargetGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobTargetGroupListResultPage type. +func NewJobTargetGroupListResultPage(cur JobTargetGroupListResult, getNextPage func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error)) JobTargetGroupListResultPage { + return JobTargetGroupListResultPage{ + fn: getNextPage, + jtglr: cur, + } +} + +// 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 - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobVersion. +func (jv JobVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobVersionListResult a list of job versions. +type JobVersionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobVersion `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobVersionListResult. +func (jvlr JobVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobVersionListResultIterator provides access to a complete listing of JobVersion values. +type JobVersionListResultIterator struct { + i int + page JobVersionListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobVersionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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()) +} + +// 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] +} + +// Creates a new instance of the JobVersionListResultIterator type. +func NewJobVersionListResultIterator(page JobVersionListResultPage) JobVersionListResultIterator { + return JobVersionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jvlr JobVersionListResult) IsEmpty() bool { + return jvlr.Value == nil || len(*jvlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jvlr JobVersionListResult) hasNextLink() bool { + return jvlr.NextLink != nil && len(*jvlr.NextLink) != 0 +} + +// jobVersionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jvlr JobVersionListResult) jobVersionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jvlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jvlr.NextLink))) +} + +// JobVersionListResultPage contains a page of JobVersion values. +type JobVersionListResultPage struct { + fn func(context.Context, JobVersionListResult) (JobVersionListResult, error) + jvlr JobVersionListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jvlr) + if err != nil { + return err + } + page.jvlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *JobVersionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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 +} + +// Creates a new instance of the JobVersionListResultPage type. +func NewJobVersionListResultPage(cur JobVersionListResult, getNextPage func(context.Context, JobVersionListResult) (JobVersionListResult, error)) JobVersionListResultPage { + return JobVersionListResultPage{ + fn: getNextPage, + jvlr: cur, + } +} + +// LicenseTypeCapability the license type capability +type LicenseTypeCapability struct { + // Name - READ-ONLY; License type identifier. + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LicenseTypeCapability. +func (ltc LicenseTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltc.Reason != nil { + objectMap["reason"] = ltc.Reason + } + return json.Marshal(objectMap) +} + +// LocationCapabilities the location capability. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedManagedInstanceVersions - READ-ONLY; The list of supported managed instance versions. + SupportedManagedInstanceVersions *[]ManagedInstanceVersionCapability `json:"supportedManagedInstanceVersions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationCapabilities. +func (lc LocationCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lc.Reason != nil { + objectMap["reason"] = lc.Reason + } + return json.Marshal(objectMap) +} + +// LogicalServerSecurityAlertPolicyListResult a list of the server's security alert policies. +type LogicalServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogicalServerSecurityAlertPolicyListResult. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LogicalServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ServerSecurityAlertPolicy values. +type LogicalServerSecurityAlertPolicyListResultIterator struct { + i int + page LogicalServerSecurityAlertPolicyListResultPage +} + +// NextWithContext 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 *LogicalServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LogicalServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LogicalServerSecurityAlertPolicyListResultIterator) 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 LogicalServerSecurityAlertPolicyListResultIterator) Response() LogicalServerSecurityAlertPolicyListResult { + 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 LogicalServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultIterator type. +func NewLogicalServerSecurityAlertPolicyListResultIterator(page LogicalServerSecurityAlertPolicyListResultPage) LogicalServerSecurityAlertPolicyListResultIterator { + return LogicalServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) IsEmpty() bool { + return lssaplr.Value == nil || len(*lssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) hasNextLink() bool { + return lssaplr.NextLink != nil && len(*lssaplr.NextLink) != 0 +} + +// logicalServerSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) logicalServerSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !lssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lssaplr.NextLink))) +} + +// LogicalServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. +type LogicalServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error) + lssaplr LogicalServerSecurityAlertPolicyListResult +} + +// NextWithContext 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 *LogicalServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.lssaplr) + if err != nil { + return err + } + page.lssaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *LogicalServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LogicalServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.lssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LogicalServerSecurityAlertPolicyListResultPage) Response() LogicalServerSecurityAlertPolicyListResult { + return page.lssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LogicalServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { + if page.lssaplr.IsEmpty() { + return nil + } + return *page.lssaplr.Value +} + +// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultPage type. +func NewLogicalServerSecurityAlertPolicyListResultPage(cur LogicalServerSecurityAlertPolicyListResult, getNextPage func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error)) LogicalServerSecurityAlertPolicyListResultPage { + return LogicalServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + lssaplr: cur, + } +} + +// LogSizeCapability the log size capability. +type LogSizeCapability struct { + // Limit - READ-ONLY; The log size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes', 'Percent' + Unit LogSizeUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSizeCapability. +func (lsc LogSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackup a long term retention backup. +type LongTermRetentionBackup struct { + autorest.Response `json:"-"` + // LongTermRetentionBackupProperties - Resource properties. + *LongTermRetentionBackupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackup. +func (ltrb LongTermRetentionBackup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrb.LongTermRetentionBackupProperties != nil { + objectMap["properties"] = ltrb.LongTermRetentionBackupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackup struct. +func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var longTermRetentionBackupProperties LongTermRetentionBackupProperties + err = json.Unmarshal(*v, &longTermRetentionBackupProperties) + if err != nil { + return err + } + ltrb.LongTermRetentionBackupProperties = &longTermRetentionBackupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ltrb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ltrb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ltrb.Type = &typeVar + } + } + } + + return nil +} + +// LongTermRetentionBackupListResult a list of long term retention backups. +type LongTermRetentionBackupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LongTermRetentionBackup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupListResult. +func (ltrblr LongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupListResultIterator provides access to a complete listing of +// LongTermRetentionBackup values. +type LongTermRetentionBackupListResultIterator struct { + i int + page LongTermRetentionBackupListResultPage +} + +// NextWithContext 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 *LongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LongTermRetentionBackupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LongTermRetentionBackupListResultIterator) 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 LongTermRetentionBackupListResultIterator) Response() LongTermRetentionBackupListResult { + 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 LongTermRetentionBackupListResultIterator) Value() LongTermRetentionBackup { + if !iter.page.NotDone() { + return LongTermRetentionBackup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LongTermRetentionBackupListResultIterator type. +func NewLongTermRetentionBackupListResultIterator(page LongTermRetentionBackupListResultPage) LongTermRetentionBackupListResultIterator { + return LongTermRetentionBackupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ltrblr LongTermRetentionBackupListResult) IsEmpty() bool { + return ltrblr.Value == nil || len(*ltrblr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ltrblr LongTermRetentionBackupListResult) hasNextLink() bool { + return ltrblr.NextLink != nil && len(*ltrblr.NextLink) != 0 +} + +// longTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ltrblr LongTermRetentionBackupListResult) longTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrblr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ltrblr.NextLink))) +} + +// LongTermRetentionBackupListResultPage contains a page of LongTermRetentionBackup values. +type LongTermRetentionBackupListResultPage struct { + fn func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error) + ltrblr LongTermRetentionBackupListResult +} + +// NextWithContext 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 *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ltrblr) + if err != nil { + return err + } + page.ltrblr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *LongTermRetentionBackupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LongTermRetentionBackupListResultPage) NotDone() bool { + return !page.ltrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LongTermRetentionBackupListResultPage) Response() LongTermRetentionBackupListResult { + return page.ltrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LongTermRetentionBackupListResultPage) Values() []LongTermRetentionBackup { + if page.ltrblr.IsEmpty() { + return nil + } + return *page.ltrblr.Value +} + +// Creates a new instance of the LongTermRetentionBackupListResultPage type. +func NewLongTermRetentionBackupListResultPage(cur LongTermRetentionBackupListResult, getNextPage func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error)) LongTermRetentionBackupListResultPage { + return LongTermRetentionBackupListResultPage{ + fn: getNextPage, + ltrblr: cur, + } +} + +// LongTermRetentionBackupProperties properties of a long term retention backup +type LongTermRetentionBackupProperties struct { + // ServerName - READ-ONLY; The server name that the backup database belong to. + ServerName *string `json:"serverName,omitempty"` + // ServerCreateTime - READ-ONLY; The create time of the server. + ServerCreateTime *date.Time `json:"serverCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupProperties. +func (ltrbp LongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupsDeleteByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsDeleteFuture.Result. +func (future *LongTermRetentionBackupsDeleteFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionManagedInstanceBackupsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionPolicyProperties properties of a long term retention policy +type LongTermRetentionPolicyProperties struct { + // WeeklyRetention - The weekly retention policy for an LTR backup in an ISO 8601 format. + WeeklyRetention *string `json:"weeklyRetention,omitempty"` + // MonthlyRetention - The monthly retention policy for an LTR backup in an ISO 8601 format. + MonthlyRetention *string `json:"monthlyRetention,omitempty"` + // YearlyRetention - The yearly retention policy for an LTR backup in an ISO 8601 format. + YearlyRetention *string `json:"yearlyRetention,omitempty"` + // WeekOfYear - The week of year to take the yearly backup in an ISO 8601 format. + WeekOfYear *int32 `json:"weekOfYear,omitempty"` +} + +// ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedBackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedBackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedBackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedBackupShortTermRetentionPolicy a short term retention policy. +type ManagedBackupShortTermRetentionPolicy struct { + autorest.Response `json:"-"` + // ManagedBackupShortTermRetentionPolicyProperties - Resource properties. + *ManagedBackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicy. +func (mbstrp ManagedBackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mbstrp.ManagedBackupShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = mbstrp.ManagedBackupShortTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedBackupShortTermRetentionPolicy struct. +func (mbstrp *ManagedBackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedBackupShortTermRetentionPolicyProperties ManagedBackupShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &managedBackupShortTermRetentionPolicyProperties) + if err != nil { + return err + } + mbstrp.ManagedBackupShortTermRetentionPolicyProperties = &managedBackupShortTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mbstrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mbstrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mbstrp.Type = &typeVar + } + } + } + + return nil +} + +// ManagedBackupShortTermRetentionPolicyListResult a list of short term retention policies. +type ManagedBackupShortTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedBackupShortTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicyListResult. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedBackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of +// ManagedBackupShortTermRetentionPolicy values. +type ManagedBackupShortTermRetentionPolicyListResultIterator struct { + i int + page ManagedBackupShortTermRetentionPolicyListResultPage +} + +// NextWithContext 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 *ManagedBackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedBackupShortTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) 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 ManagedBackupShortTermRetentionPolicyListResultIterator) Response() ManagedBackupShortTermRetentionPolicyListResult { + 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 ManagedBackupShortTermRetentionPolicyListResultIterator) Value() ManagedBackupShortTermRetentionPolicy { + if !iter.page.NotDone() { + return ManagedBackupShortTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultIterator type. +func NewManagedBackupShortTermRetentionPolicyListResultIterator(page ManagedBackupShortTermRetentionPolicyListResultPage) ManagedBackupShortTermRetentionPolicyListResultIterator { + return ManagedBackupShortTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) IsEmpty() bool { + return mbstrplr.Value == nil || len(*mbstrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) hasNextLink() bool { + return mbstrplr.NextLink != nil && len(*mbstrplr.NextLink) != 0 +} + +// managedBackupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) managedBackupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mbstrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mbstrplr.NextLink))) +} + +// ManagedBackupShortTermRetentionPolicyListResultPage contains a page of +// ManagedBackupShortTermRetentionPolicy values. +type ManagedBackupShortTermRetentionPolicyListResultPage struct { + fn func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error) + mbstrplr ManagedBackupShortTermRetentionPolicyListResult +} + +// NextWithContext 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 *ManagedBackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mbstrplr) + if err != nil { + return err + } + page.mbstrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedBackupShortTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedBackupShortTermRetentionPolicyListResultPage) NotDone() bool { + return !page.mbstrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedBackupShortTermRetentionPolicyListResultPage) Response() ManagedBackupShortTermRetentionPolicyListResult { + return page.mbstrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedBackupShortTermRetentionPolicyListResultPage) Values() []ManagedBackupShortTermRetentionPolicy { + if page.mbstrplr.IsEmpty() { + return nil + } + return *page.mbstrplr.Value +} + +// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultPage type. +func NewManagedBackupShortTermRetentionPolicyListResultPage(cur ManagedBackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error)) ManagedBackupShortTermRetentionPolicyListResultPage { + return ManagedBackupShortTermRetentionPolicyListResultPage{ + fn: getNextPage, + mbstrplr: cur, + } +} + +// ManagedBackupShortTermRetentionPolicyProperties properties of a short term retention policy +type ManagedBackupShortTermRetentionPolicyProperties struct { + // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + +// ManagedDatabase a managed database resource. +type ManagedDatabase struct { + autorest.Response `json:"-"` + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabase. +func (md ManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if md.ManagedDatabaseProperties != nil { + objectMap["properties"] = md.ManagedDatabaseProperties + } + if md.Location != nil { + objectMap["location"] = md.Location + } + if md.Tags != nil { + objectMap["tags"] = md.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabase struct. +func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedDatabaseProperties ManagedDatabaseProperties + err = json.Unmarshal(*v, &managedDatabaseProperties) + if err != nil { + return err + } + md.ManagedDatabaseProperties = &managedDatabaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + md.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + md.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + md.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + md.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + md.Type = &typeVar + } + } + } + + return nil +} + +// ManagedDatabaseListResult a list of managed databases. +type ManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseListResult. +func (mdlr ManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseListResultIterator provides access to a complete listing of ManagedDatabase values. +type ManagedDatabaseListResultIterator struct { + i int + page ManagedDatabaseListResultPage +} + +// NextWithContext 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 *ManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedDatabaseListResultIterator) 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 ManagedDatabaseListResultIterator) Response() ManagedDatabaseListResult { + 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 ManagedDatabaseListResultIterator) Value() ManagedDatabase { + if !iter.page.NotDone() { + return ManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedDatabaseListResultIterator type. +func NewManagedDatabaseListResultIterator(page ManagedDatabaseListResultPage) ManagedDatabaseListResultIterator { + return ManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mdlr ManagedDatabaseListResult) IsEmpty() bool { + return mdlr.Value == nil || len(*mdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mdlr ManagedDatabaseListResult) hasNextLink() bool { + return mdlr.NextLink != nil && len(*mdlr.NextLink) != 0 +} + +// managedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mdlr ManagedDatabaseListResult) managedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mdlr.NextLink))) +} + +// ManagedDatabaseListResultPage contains a page of ManagedDatabase values. +type ManagedDatabaseListResultPage struct { + fn func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error) + mdlr ManagedDatabaseListResult +} + +// NextWithContext 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 *ManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mdlr) + if err != nil { + return err + } + page.mdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedDatabaseListResultPage) NotDone() bool { + return !page.mdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedDatabaseListResultPage) Response() ManagedDatabaseListResult { + return page.mdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedDatabaseListResultPage) Values() []ManagedDatabase { + if page.mdlr.IsEmpty() { + return nil + } + return *page.mdlr.Value +} + +// Creates a new instance of the ManagedDatabaseListResultPage type. +func NewManagedDatabaseListResultPage(cur ManagedDatabaseListResult, getNextPage func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error)) ManagedDatabaseListResultPage { + return ManagedDatabaseListResultPage{ + fn: getNextPage, + mdlr: cur, + } +} + +// ManagedDatabaseProperties the managed database's properties. +type ManagedDatabaseProperties struct { + // Collation - Collation of the managed database. + Collation *string `json:"collation,omitempty"` + // Status - READ-ONLY; Status of the database. Possible values include: 'Online', 'Offline', 'Shutdown', 'Creating', 'Inaccessible', 'Restoring', 'Updating' + Status ManagedDatabaseStatus `json:"status,omitempty"` + // CreationDate - READ-ONLY; Creation date of the database. + CreationDate *date.Time `json:"creationDate,omitempty"` + // EarliestRestorePoint - READ-ONLY; Earliest restore point in time for point in time restore. + EarliestRestorePoint *date.Time `json:"earliestRestorePoint,omitempty"` + // RestorePointInTime - Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; Geo paired region. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'DATABASEDEFAULT', 'SQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // CreateMode - Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a long term retention backup (longTermRetentionBackupResourceId required). Possible values include: 'ManagedDatabaseCreateModeDefault', 'ManagedDatabaseCreateModeRestoreExternalBackup', 'ManagedDatabaseCreateModePointInTimeRestore', 'ManagedDatabaseCreateModeRecovery', 'ManagedDatabaseCreateModeRestoreLongTermRetentionBackup' + CreateMode ManagedDatabaseCreateMode `json:"createMode,omitempty"` + // StorageContainerURI - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri of the storage container where backups for this restore are stored. + StorageContainerURI *string `json:"storageContainerUri,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The restorable dropped database resource id to restore when creating this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // StorageContainerSasToken - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. + StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` + // FailoverGroupID - READ-ONLY; Instance Failover Group resource identifier that this managed database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // LongTermRetentionBackupResourceID - The name of the Long Term Retention backup to be used for restore of this managed database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // AutoCompleteRestore - Whether to auto complete restore of this managed database. + AutoCompleteRestore *bool `json:"autoCompleteRestore,omitempty"` + // LastBackupName - Last backup file name for restore of this managed database. + LastBackupName *string `json:"lastBackupName,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseProperties. +func (mdp ManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdp.Collation != nil { + objectMap["collation"] = mdp.Collation + } + if mdp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mdp.RestorePointInTime + } + if mdp.CatalogCollation != "" { + objectMap["catalogCollation"] = mdp.CatalogCollation + } + if mdp.CreateMode != "" { + objectMap["createMode"] = mdp.CreateMode + } + if mdp.StorageContainerURI != nil { + objectMap["storageContainerUri"] = mdp.StorageContainerURI + } + if mdp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = mdp.SourceDatabaseID + } + if mdp.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = mdp.RestorableDroppedDatabaseID + } + if mdp.StorageContainerSasToken != nil { + objectMap["storageContainerSasToken"] = mdp.StorageContainerSasToken + } + if mdp.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = mdp.RecoverableDatabaseID + } + if mdp.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = mdp.LongTermRetentionBackupResourceID + } + if mdp.AutoCompleteRestore != nil { + objectMap["autoCompleteRestore"] = mdp.AutoCompleteRestore + } + if mdp.LastBackupName != nil { + objectMap["lastBackupName"] = mdp.LastBackupName + } + return json.Marshal(objectMap) +} + +// ManagedDatabasesCompleteRestoreFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedDatabasesCompleteRestoreFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesCompleteRestoreFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesCompleteRestoreFuture.Result. +func (future *ManagedDatabasesCompleteRestoreFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCompleteRestoreFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedDatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedDatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (ManagedDatabase, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesCreateOrUpdateFuture.Result. +func (future *ManagedDatabasesCreateOrUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + md.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { + md, err = client.CreateOrUpdateResponder(md.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", md.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedDatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesDeleteFuture.Result. +func (future *ManagedDatabasesDeleteFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedDatabaseSecurityAlertPolicy a managed database security alert policy. +type ManagedDatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicy. +func (mdsap ManagedDatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdsap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = mdsap.SecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseSecurityAlertPolicy struct. +func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + mdsap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdsap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdsap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdsap.Type = &typeVar + } + } + } + + return nil +} + +// ManagedDatabaseSecurityAlertPolicyListResult a list of the managed database's security alert policies. +type ManagedDatabaseSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedDatabaseSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicyListResult. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ManagedDatabaseSecurityAlertPolicy values. +type ManagedDatabaseSecurityAlertPolicyListResultIterator struct { + i int + page ManagedDatabaseSecurityAlertPolicyListResultPage +} + +// NextWithContext 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 *ManagedDatabaseSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) 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 ManagedDatabaseSecurityAlertPolicyListResultIterator) Response() ManagedDatabaseSecurityAlertPolicyListResult { + 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 ManagedDatabaseSecurityAlertPolicyListResultIterator) Value() ManagedDatabaseSecurityAlertPolicy { + if !iter.page.NotDone() { + return ManagedDatabaseSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultIterator type. +func NewManagedDatabaseSecurityAlertPolicyListResultIterator(page ManagedDatabaseSecurityAlertPolicyListResultPage) ManagedDatabaseSecurityAlertPolicyListResultIterator { + return ManagedDatabaseSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) IsEmpty() bool { + return mdsaplr.Value == nil || len(*mdsaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) hasNextLink() bool { + return mdsaplr.NextLink != nil && len(*mdsaplr.NextLink) != 0 +} + +// managedDatabaseSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) managedDatabaseSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mdsaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mdsaplr.NextLink))) +} + +// ManagedDatabaseSecurityAlertPolicyListResultPage contains a page of ManagedDatabaseSecurityAlertPolicy +// values. +type ManagedDatabaseSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error) + mdsaplr ManagedDatabaseSecurityAlertPolicyListResult +} + +// NextWithContext 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 *ManagedDatabaseSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mdsaplr) + if err != nil { + return err + } + page.mdsaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.mdsaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Response() ManagedDatabaseSecurityAlertPolicyListResult { + return page.mdsaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Values() []ManagedDatabaseSecurityAlertPolicy { + if page.mdsaplr.IsEmpty() { + return nil + } + return *page.mdsaplr.Value +} + +// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultPage type. +func NewManagedDatabaseSecurityAlertPolicyListResultPage(cur ManagedDatabaseSecurityAlertPolicyListResult, getNextPage func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error)) ManagedDatabaseSecurityAlertPolicyListResultPage { + return ManagedDatabaseSecurityAlertPolicyListResultPage{ + fn: getNextPage, + mdsaplr: cur, + } +} + +// ManagedDatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (ManagedDatabase, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesUpdateFuture.Result. +func (future *ManagedDatabasesUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + md.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { + md, err = client.UpdateResponder(md.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", md.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedDatabaseUpdate an managed database update. +type ManagedDatabaseUpdate struct { + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseUpdate. +func (mdu ManagedDatabaseUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdu.ManagedDatabaseProperties != nil { + objectMap["properties"] = mdu.ManagedDatabaseProperties + } + if mdu.Tags != nil { + objectMap["tags"] = mdu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseUpdate struct. +func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedDatabaseProperties ManagedDatabaseProperties + err = json.Unmarshal(*v, &managedDatabaseProperties) + if err != nil { + return err + } + mdu.ManagedDatabaseProperties = &managedDatabaseProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mdu.Tags = tags + } + } + } + + return nil +} + +// ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client ManagedDatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstance an Azure SQL managed instance. +type ManagedInstance struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the managed instance. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Sku - Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, BC_Gen5 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstance. +func (mi ManagedInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mi.Identity != nil { + objectMap["identity"] = mi.Identity + } + if mi.Sku != nil { + objectMap["sku"] = mi.Sku + } + if mi.ManagedInstanceProperties != nil { + objectMap["properties"] = mi.ManagedInstanceProperties + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.Tags != nil { + objectMap["tags"] = mi.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstance struct. +func (mi *ManagedInstance) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mi.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + mi.Sku = &sku + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + mi.ManagedInstanceProperties = &managedInstanceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mi.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAdministrator an Azure SQL managed instance administrator. +type ManagedInstanceAdministrator struct { + autorest.Response `json:"-"` + // ManagedInstanceAdministratorProperties - Resource properties. + *ManagedInstanceAdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAdministrator. +func (mia ManagedInstanceAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mia.ManagedInstanceAdministratorProperties != nil { + objectMap["properties"] = mia.ManagedInstanceAdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAdministrator struct. +func (mia *ManagedInstanceAdministrator) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceAdministratorProperties ManagedInstanceAdministratorProperties + err = json.Unmarshal(*v, &managedInstanceAdministratorProperties) + if err != nil { + return err + } + mia.ManagedInstanceAdministratorProperties = &managedInstanceAdministratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mia.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mia.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mia.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAdministratorListResult a list of managed instance administrators. +type ManagedInstanceAdministratorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceAdministrator `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAdministratorListResult. +func (mialr ManagedInstanceAdministratorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceAdministratorListResultIterator provides access to a complete listing of +// ManagedInstanceAdministrator values. +type ManagedInstanceAdministratorListResultIterator struct { + i int + page ManagedInstanceAdministratorListResultPage +} + +// NextWithContext 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 *ManagedInstanceAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceAdministratorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceAdministratorListResultIterator) 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 ManagedInstanceAdministratorListResultIterator) Response() ManagedInstanceAdministratorListResult { + 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 ManagedInstanceAdministratorListResultIterator) Value() ManagedInstanceAdministrator { + if !iter.page.NotDone() { + return ManagedInstanceAdministrator{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceAdministratorListResultIterator type. +func NewManagedInstanceAdministratorListResultIterator(page ManagedInstanceAdministratorListResultPage) ManagedInstanceAdministratorListResultIterator { + return ManagedInstanceAdministratorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mialr ManagedInstanceAdministratorListResult) IsEmpty() bool { + return mialr.Value == nil || len(*mialr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mialr ManagedInstanceAdministratorListResult) hasNextLink() bool { + return mialr.NextLink != nil && len(*mialr.NextLink) != 0 +} + +// managedInstanceAdministratorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mialr ManagedInstanceAdministratorListResult) managedInstanceAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mialr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mialr.NextLink))) +} + +// ManagedInstanceAdministratorListResultPage contains a page of ManagedInstanceAdministrator values. +type ManagedInstanceAdministratorListResultPage struct { + fn func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error) + mialr ManagedInstanceAdministratorListResult +} + +// NextWithContext 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 *ManagedInstanceAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mialr) + if err != nil { + return err + } + page.mialr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceAdministratorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceAdministratorListResultPage) NotDone() bool { + return !page.mialr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceAdministratorListResultPage) Response() ManagedInstanceAdministratorListResult { + return page.mialr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceAdministratorListResultPage) Values() []ManagedInstanceAdministrator { + if page.mialr.IsEmpty() { + return nil + } + return *page.mialr.Value +} + +// Creates a new instance of the ManagedInstanceAdministratorListResultPage type. +func NewManagedInstanceAdministratorListResultPage(cur ManagedInstanceAdministratorListResult, getNextPage func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error)) ManagedInstanceAdministratorListResultPage { + return ManagedInstanceAdministratorListResultPage{ + fn: getNextPage, + mialr: cur, + } +} + +// ManagedInstanceAdministratorProperties the properties of a managed instance administrator. +type ManagedInstanceAdministratorProperties struct { + // AdministratorType - Type of the managed instance administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - Login name of the managed instance administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the managed instance administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the managed instance administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// ManagedInstanceAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceAdministratorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAdministratorsClient) (ManagedInstanceAdministrator, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAdministratorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) result(client ManagedInstanceAdministratorsClient) (mia ManagedInstanceAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mia.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mia.Response.Response, err = future.GetResult(sender); err == nil && mia.Response.Response.StatusCode != http.StatusNoContent { + mia, err = client.CreateOrUpdateResponder(mia.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", mia.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceAdministratorsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAdministratorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAdministratorsDeleteFuture.Result. +func (future *ManagedInstanceAdministratorsDeleteFuture) result(client ManagedInstanceAdministratorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceAzureADOnlyAuthentication azure Active Directory only authentication. +type ManagedInstanceAzureADOnlyAuthentication struct { + autorest.Response `json:"-"` + // ManagedInstanceAzureADOnlyAuthProperties - Resource properties. + *ManagedInstanceAzureADOnlyAuthProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthentication. +func (miaaoa ManagedInstanceAzureADOnlyAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miaaoa.ManagedInstanceAzureADOnlyAuthProperties != nil { + objectMap["properties"] = miaaoa.ManagedInstanceAzureADOnlyAuthProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAzureADOnlyAuthentication struct. +func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceAzureADOnlyAuthProperties ManagedInstanceAzureADOnlyAuthProperties + err = json.Unmarshal(*v, &managedInstanceAzureADOnlyAuthProperties) + if err != nil { + return err + } + miaaoa.ManagedInstanceAzureADOnlyAuthProperties = &managedInstanceAzureADOnlyAuthProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miaaoa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miaaoa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miaaoa.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (ManagedInstanceAzureADOnlyAuthentication, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (miaaoa ManagedInstanceAzureADOnlyAuthentication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miaaoa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miaaoa.Response.Response, err = future.GetResult(sender); err == nil && miaaoa.Response.Response.StatusCode != http.StatusNoContent { + miaaoa, err = client.CreateOrUpdateResponder(miaaoa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", miaaoa.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture.Result. +func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceAzureADOnlyAuthListResult a list of active directory only authentications. +type ManagedInstanceAzureADOnlyAuthListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceAzureADOnlyAuthentication `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthListResult. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceAzureADOnlyAuthListResultIterator provides access to a complete listing of +// ManagedInstanceAzureADOnlyAuthentication values. +type ManagedInstanceAzureADOnlyAuthListResultIterator struct { + i int + page ManagedInstanceAzureADOnlyAuthListResultPage +} + +// NextWithContext 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 *ManagedInstanceAzureADOnlyAuthListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceAzureADOnlyAuthListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) 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 ManagedInstanceAzureADOnlyAuthListResultIterator) Response() ManagedInstanceAzureADOnlyAuthListResult { + 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 ManagedInstanceAzureADOnlyAuthListResultIterator) Value() ManagedInstanceAzureADOnlyAuthentication { + if !iter.page.NotDone() { + return ManagedInstanceAzureADOnlyAuthentication{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultIterator type. +func NewManagedInstanceAzureADOnlyAuthListResultIterator(page ManagedInstanceAzureADOnlyAuthListResultPage) ManagedInstanceAzureADOnlyAuthListResultIterator { + return ManagedInstanceAzureADOnlyAuthListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) IsEmpty() bool { + return miaaoalr.Value == nil || len(*miaaoalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) hasNextLink() bool { + return miaaoalr.NextLink != nil && len(*miaaoalr.NextLink) != 0 +} + +// managedInstanceAzureADOnlyAuthListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) managedInstanceAzureADOnlyAuthListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miaaoalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miaaoalr.NextLink))) +} + +// ManagedInstanceAzureADOnlyAuthListResultPage contains a page of ManagedInstanceAzureADOnlyAuthentication +// values. +type ManagedInstanceAzureADOnlyAuthListResultPage struct { + fn func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error) + miaaoalr ManagedInstanceAzureADOnlyAuthListResult +} + +// NextWithContext 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 *ManagedInstanceAzureADOnlyAuthListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miaaoalr) + if err != nil { + return err + } + page.miaaoalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceAzureADOnlyAuthListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceAzureADOnlyAuthListResultPage) NotDone() bool { + return !page.miaaoalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceAzureADOnlyAuthListResultPage) Response() ManagedInstanceAzureADOnlyAuthListResult { + return page.miaaoalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceAzureADOnlyAuthListResultPage) Values() []ManagedInstanceAzureADOnlyAuthentication { + if page.miaaoalr.IsEmpty() { + return nil + } + return *page.miaaoalr.Value +} + +// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultPage type. +func NewManagedInstanceAzureADOnlyAuthListResultPage(cur ManagedInstanceAzureADOnlyAuthListResult, getNextPage func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error)) ManagedInstanceAzureADOnlyAuthListResultPage { + return ManagedInstanceAzureADOnlyAuthListResultPage{ + fn: getNextPage, + miaaoalr: cur, + } +} + +// ManagedInstanceAzureADOnlyAuthProperties properties of a active directory only authentication for +// Managed Instance. +type ManagedInstanceAzureADOnlyAuthProperties struct { + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// ManagedInstanceEditionCapability the managed server capability +type ManagedInstanceEditionCapability struct { + // Name - READ-ONLY; The managed server version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]ManagedInstanceFamilyCapability `json:"supportedFamilies,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEditionCapability. +func (miec ManagedInstanceEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miec.Reason != nil { + objectMap["reason"] = miec.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtector the managed instance encryption protector. +type ManagedInstanceEncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceEncryptionProtectorProperties - Resource properties. + *ManagedInstanceEncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtector. +func (miep ManagedInstanceEncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miep.ManagedInstanceEncryptionProtectorProperties != nil { + objectMap["properties"] = miep.ManagedInstanceEncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceEncryptionProtector struct. +func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + miep.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceEncryptionProtectorProperties ManagedInstanceEncryptionProtectorProperties + err = json.Unmarshal(*v, &managedInstanceEncryptionProtectorProperties) + if err != nil { + return err + } + miep.ManagedInstanceEncryptionProtectorProperties = &managedInstanceEncryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miep.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceEncryptionProtectorListResult a list of managed instance encryption protectors. +type ManagedInstanceEncryptionProtectorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceEncryptionProtector `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorListResult. +func (mieplr ManagedInstanceEncryptionProtectorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtectorListResultIterator provides access to a complete listing of +// ManagedInstanceEncryptionProtector values. +type ManagedInstanceEncryptionProtectorListResultIterator struct { + i int + page ManagedInstanceEncryptionProtectorListResultPage +} + +// NextWithContext 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 *ManagedInstanceEncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceEncryptionProtectorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceEncryptionProtectorListResultIterator) 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 ManagedInstanceEncryptionProtectorListResultIterator) Response() ManagedInstanceEncryptionProtectorListResult { + 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 ManagedInstanceEncryptionProtectorListResultIterator) Value() ManagedInstanceEncryptionProtector { + if !iter.page.NotDone() { + return ManagedInstanceEncryptionProtector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultIterator type. +func NewManagedInstanceEncryptionProtectorListResultIterator(page ManagedInstanceEncryptionProtectorListResultPage) ManagedInstanceEncryptionProtectorListResultIterator { + return ManagedInstanceEncryptionProtectorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mieplr ManagedInstanceEncryptionProtectorListResult) IsEmpty() bool { + return mieplr.Value == nil || len(*mieplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mieplr ManagedInstanceEncryptionProtectorListResult) hasNextLink() bool { + return mieplr.NextLink != nil && len(*mieplr.NextLink) != 0 +} + +// managedInstanceEncryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mieplr ManagedInstanceEncryptionProtectorListResult) managedInstanceEncryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mieplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mieplr.NextLink))) +} + +// ManagedInstanceEncryptionProtectorListResultPage contains a page of ManagedInstanceEncryptionProtector +// values. +type ManagedInstanceEncryptionProtectorListResultPage struct { + fn func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error) + mieplr ManagedInstanceEncryptionProtectorListResult +} + +// NextWithContext 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 *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mieplr) + if err != nil { + return err + } + page.mieplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceEncryptionProtectorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceEncryptionProtectorListResultPage) NotDone() bool { + return !page.mieplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceEncryptionProtectorListResultPage) Response() ManagedInstanceEncryptionProtectorListResult { + return page.mieplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceEncryptionProtectorListResultPage) Values() []ManagedInstanceEncryptionProtector { + if page.mieplr.IsEmpty() { + return nil + } + return *page.mieplr.Value +} + +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultPage type. +func NewManagedInstanceEncryptionProtectorListResultPage(cur ManagedInstanceEncryptionProtectorListResult, getNextPage func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error)) ManagedInstanceEncryptionProtectorListResultPage { + return ManagedInstanceEncryptionProtectorListResultPage{ + fn: getNextPage, + mieplr: cur, + } +} + +// ManagedInstanceEncryptionProtectorProperties properties for an encryption protector execution. +type ManagedInstanceEncryptionProtectorProperties struct { + // ServerKeyName - The name of the managed instance key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorProperties. +func (miepp ManagedInstanceEncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miepp.ServerKeyName != nil { + objectMap["serverKeyName"] = miepp.ServerKeyName + } + if miepp.ServerKeyType != "" { + objectMap["serverKeyType"] = miepp.ServerKeyType + } + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (ManagedInstanceEncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (miep ManagedInstanceEncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miep.Response.Response, err = future.GetResult(sender); err == nil && miep.Response.Response.StatusCode != http.StatusNoContent { + miep, err = client.CreateOrUpdateResponder(miep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", miep.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceEncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsRevalidateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceFamilyCapability the managed server family capability. +type ManagedInstanceFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // Sku - READ-ONLY; SKU name. + Sku *string `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]ManagedInstanceVcoresCapability `json:"supportedVcoresValues,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceFamilyCapability. +func (mifc ManagedInstanceFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mifc.Reason != nil { + objectMap["reason"] = mifc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKey a managed instance key. +type ManagedInstanceKey struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceKeyProperties - Resource properties. + *ManagedInstanceKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKey. +func (mik ManagedInstanceKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mik.ManagedInstanceKeyProperties != nil { + objectMap["properties"] = mik.ManagedInstanceKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceKey struct. +func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mik.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceKeyProperties ManagedInstanceKeyProperties + err = json.Unmarshal(*v, &managedInstanceKeyProperties) + if err != nil { + return err + } + mik.ManagedInstanceKeyProperties = &managedInstanceKeyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mik.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mik.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mik.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceKeyListResult a list of managed instance keys. +type ManagedInstanceKeyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceKey `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKeyListResult. +func (miklr ManagedInstanceKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceKeyListResultIterator provides access to a complete listing of ManagedInstanceKey values. +type ManagedInstanceKeyListResultIterator struct { + i int + page ManagedInstanceKeyListResultPage +} + +// NextWithContext 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 *ManagedInstanceKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceKeyListResultIterator) 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 ManagedInstanceKeyListResultIterator) Response() ManagedInstanceKeyListResult { + 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 ManagedInstanceKeyListResultIterator) Value() ManagedInstanceKey { + if !iter.page.NotDone() { + return ManagedInstanceKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceKeyListResultIterator type. +func NewManagedInstanceKeyListResultIterator(page ManagedInstanceKeyListResultPage) ManagedInstanceKeyListResultIterator { + return ManagedInstanceKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miklr ManagedInstanceKeyListResult) IsEmpty() bool { + return miklr.Value == nil || len(*miklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miklr ManagedInstanceKeyListResult) hasNextLink() bool { + return miklr.NextLink != nil && len(*miklr.NextLink) != 0 +} + +// managedInstanceKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miklr ManagedInstanceKeyListResult) managedInstanceKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miklr.NextLink))) +} + +// ManagedInstanceKeyListResultPage contains a page of ManagedInstanceKey values. +type ManagedInstanceKeyListResultPage struct { + fn func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error) + miklr ManagedInstanceKeyListResult +} + +// NextWithContext 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 *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miklr) + if err != nil { + return err + } + page.miklr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceKeyListResultPage) NotDone() bool { + return !page.miklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceKeyListResultPage) Response() ManagedInstanceKeyListResult { + return page.miklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceKeyListResultPage) Values() []ManagedInstanceKey { + if page.miklr.IsEmpty() { + return nil + } + return *page.miklr.Value +} + +// Creates a new instance of the ManagedInstanceKeyListResultPage type. +func NewManagedInstanceKeyListResultPage(cur ManagedInstanceKeyListResult, getNextPage func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error)) ManagedInstanceKeyListResultPage { + return ManagedInstanceKeyListResultPage{ + fn: getNextPage, + miklr: cur, + } +} + +// ManagedInstanceKeyProperties properties for a key execution. +type ManagedInstanceKeyProperties struct { + // ServerKeyType - The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - READ-ONLY; The key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKeyProperties. +func (mikp ManagedInstanceKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mikp.ServerKeyType != "" { + objectMap["serverKeyType"] = mikp.ServerKeyType + } + if mikp.URI != nil { + objectMap["uri"] = mikp.URI + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (ManagedInstanceKey, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceKeysCreateOrUpdateFuture.Result. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) result(client ManagedInstanceKeysClient) (mik ManagedInstanceKey, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mik.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mik.Response.Response, err = future.GetResult(sender); err == nil && mik.Response.Response.StatusCode != http.StatusNoContent { + mik, err = client.CreateOrUpdateResponder(mik.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", mik.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceKeysDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceKeysDeleteFuture.Result. +func (future *ManagedInstanceKeysDeleteFuture) result(client ManagedInstanceKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceListResult a list of managed instances. +type ManagedInstanceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceListResult. +func (milr ManagedInstanceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// NextWithContext 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 *ManagedInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceListResultIterator) 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 ManagedInstanceListResultIterator) Response() ManagedInstanceListResult { + 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 ManagedInstanceListResultIterator) Value() ManagedInstance { + if !iter.page.NotDone() { + return ManagedInstance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceListResultIterator type. +func NewManagedInstanceListResultIterator(page ManagedInstanceListResultPage) ManagedInstanceListResultIterator { + return ManagedInstanceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (milr ManagedInstanceListResult) hasNextLink() bool { + return milr.NextLink != nil && len(*milr.NextLink) != 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !milr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// NextWithContext 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 *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.milr) + if err != nil { + return err + } + page.milr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceListResultPage) NotDone() bool { + return !page.milr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceListResultPage) Response() ManagedInstanceListResult { + return page.milr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceListResultPage) Values() []ManagedInstance { + if page.milr.IsEmpty() { + return nil + } + return *page.milr.Value +} + +// Creates a new instance of the ManagedInstanceListResultPage type. +func NewManagedInstanceListResultPage(cur ManagedInstanceListResult, getNextPage func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error)) ManagedInstanceListResultPage { + return ManagedInstanceListResultPage{ + fn: getNextPage, + milr: cur, + } +} + +// ManagedInstanceLongTermRetentionBackup a long term retention backup for a managed database. +type ManagedInstanceLongTermRetentionBackup struct { + autorest.Response `json:"-"` + // ManagedInstanceLongTermRetentionBackupProperties - Resource properties. + *ManagedInstanceLongTermRetentionBackupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackup. +func (miltrb ManagedInstanceLongTermRetentionBackup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miltrb.ManagedInstanceLongTermRetentionBackupProperties != nil { + objectMap["properties"] = miltrb.ManagedInstanceLongTermRetentionBackupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionBackup struct. +func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceLongTermRetentionBackupProperties ManagedInstanceLongTermRetentionBackupProperties + err = json.Unmarshal(*v, &managedInstanceLongTermRetentionBackupProperties) + if err != nil { + return err + } + miltrb.ManagedInstanceLongTermRetentionBackupProperties = &managedInstanceLongTermRetentionBackupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miltrb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miltrb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miltrb.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceLongTermRetentionBackupListResult a list of long term retention backups for managed +// database(s). +type ManagedInstanceLongTermRetentionBackupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceLongTermRetentionBackup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupListResult. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceLongTermRetentionBackupListResultIterator provides access to a complete listing of +// ManagedInstanceLongTermRetentionBackup values. +type ManagedInstanceLongTermRetentionBackupListResultIterator struct { + i int + page ManagedInstanceLongTermRetentionBackupListResultPage +} + +// NextWithContext 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 *ManagedInstanceLongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) 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 ManagedInstanceLongTermRetentionBackupListResultIterator) Response() ManagedInstanceLongTermRetentionBackupListResult { + 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 ManagedInstanceLongTermRetentionBackupListResultIterator) Value() ManagedInstanceLongTermRetentionBackup { + if !iter.page.NotDone() { + return ManagedInstanceLongTermRetentionBackup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultIterator type. +func NewManagedInstanceLongTermRetentionBackupListResultIterator(page ManagedInstanceLongTermRetentionBackupListResultPage) ManagedInstanceLongTermRetentionBackupListResultIterator { + return ManagedInstanceLongTermRetentionBackupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) IsEmpty() bool { + return miltrblr.Value == nil || len(*miltrblr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) hasNextLink() bool { + return miltrblr.NextLink != nil && len(*miltrblr.NextLink) != 0 +} + +// managedInstanceLongTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) managedInstanceLongTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miltrblr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miltrblr.NextLink))) +} + +// ManagedInstanceLongTermRetentionBackupListResultPage contains a page of +// ManagedInstanceLongTermRetentionBackup values. +type ManagedInstanceLongTermRetentionBackupListResultPage struct { + fn func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error) + miltrblr ManagedInstanceLongTermRetentionBackupListResult +} + +// NextWithContext 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 *ManagedInstanceLongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miltrblr) + if err != nil { + return err + } + page.miltrblr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceLongTermRetentionBackupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceLongTermRetentionBackupListResultPage) NotDone() bool { + return !page.miltrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceLongTermRetentionBackupListResultPage) Response() ManagedInstanceLongTermRetentionBackupListResult { + return page.miltrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceLongTermRetentionBackupListResultPage) Values() []ManagedInstanceLongTermRetentionBackup { + if page.miltrblr.IsEmpty() { + return nil + } + return *page.miltrblr.Value +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultPage type. +func NewManagedInstanceLongTermRetentionBackupListResultPage(cur ManagedInstanceLongTermRetentionBackupListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error)) ManagedInstanceLongTermRetentionBackupListResultPage { + return ManagedInstanceLongTermRetentionBackupListResultPage{ + fn: getNextPage, + miltrblr: cur, + } +} + +// ManagedInstanceLongTermRetentionBackupProperties properties of a long term retention backup +type ManagedInstanceLongTermRetentionBackupProperties struct { + // ManagedInstanceName - READ-ONLY; The managed instance that the backup database belongs to. + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + // ManagedInstanceCreateTime - READ-ONLY; The create time of the instance. + ManagedInstanceCreateTime *date.Time `json:"managedInstanceCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupProperties. +func (miltrbp ManagedInstanceLongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceLongTermRetentionPoliciesClient) (ManagedInstanceLongTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedInstanceLongTermRetentionPoliciesClient) (miltrp ManagedInstanceLongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miltrp.Response.Response, err = future.GetResult(sender); err == nil && miltrp.Response.Response.StatusCode != http.StatusNoContent { + miltrp, err = client.CreateOrUpdateResponder(miltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", miltrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceLongTermRetentionPolicy a long term retention policy. +type ManagedInstanceLongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BaseLongTermRetentionPolicyProperties - Resource properties. + *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicy. +func (miltrp ManagedInstanceLongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miltrp.BaseLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = miltrp.BaseLongTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionPolicy struct. +func (miltrp *ManagedInstanceLongTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) + if err != nil { + return err + } + miltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miltrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miltrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miltrp.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceLongTermRetentionPolicyListResult a list of long term retention policies. +type ManagedInstanceLongTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceLongTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicyListResult. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceLongTermRetentionPolicyListResultIterator provides access to a complete listing of +// ManagedInstanceLongTermRetentionPolicy values. +type ManagedInstanceLongTermRetentionPolicyListResultIterator struct { + i int + page ManagedInstanceLongTermRetentionPolicyListResultPage +} + +// NextWithContext 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 *ManagedInstanceLongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) 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 ManagedInstanceLongTermRetentionPolicyListResultIterator) Response() ManagedInstanceLongTermRetentionPolicyListResult { + 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 ManagedInstanceLongTermRetentionPolicyListResultIterator) Value() ManagedInstanceLongTermRetentionPolicy { + if !iter.page.NotDone() { + return ManagedInstanceLongTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultIterator type. +func NewManagedInstanceLongTermRetentionPolicyListResultIterator(page ManagedInstanceLongTermRetentionPolicyListResultPage) ManagedInstanceLongTermRetentionPolicyListResultIterator { + return ManagedInstanceLongTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) IsEmpty() bool { + return miltrplr.Value == nil || len(*miltrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) hasNextLink() bool { + return miltrplr.NextLink != nil && len(*miltrplr.NextLink) != 0 +} + +// managedInstanceLongTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) managedInstanceLongTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miltrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miltrplr.NextLink))) +} + +// ManagedInstanceLongTermRetentionPolicyListResultPage contains a page of +// ManagedInstanceLongTermRetentionPolicy values. +type ManagedInstanceLongTermRetentionPolicyListResultPage struct { + fn func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error) + miltrplr ManagedInstanceLongTermRetentionPolicyListResult +} + +// NextWithContext 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 *ManagedInstanceLongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miltrplr) + if err != nil { + return err + } + page.miltrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) NotDone() bool { + return !page.miltrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Response() ManagedInstanceLongTermRetentionPolicyListResult { + return page.miltrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Values() []ManagedInstanceLongTermRetentionPolicy { + if page.miltrplr.IsEmpty() { + return nil + } + return *page.miltrplr.Value +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultPage type. +func NewManagedInstanceLongTermRetentionPolicyListResultPage(cur ManagedInstanceLongTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error)) ManagedInstanceLongTermRetentionPolicyListResultPage { + return ManagedInstanceLongTermRetentionPolicyListResultPage{ + fn: getNextPage, + miltrplr: cur, + } +} + +// ManagedInstanceOperation a managed instance operation. +type ManagedInstanceOperation struct { + autorest.Response `json:"-"` + // ManagedInstanceOperationProperties - Resource properties. + *ManagedInstanceOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperation. +func (mio ManagedInstanceOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mio.ManagedInstanceOperationProperties != nil { + objectMap["properties"] = mio.ManagedInstanceOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceOperation struct. +func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceOperationProperties ManagedInstanceOperationProperties + err = json.Unmarshal(*v, &managedInstanceOperationProperties) + if err != nil { + return err + } + mio.ManagedInstanceOperationProperties = &managedInstanceOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mio.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mio.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mio.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceOperationListResult the response to a list managed instance operations request +type ManagedInstanceOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationListResult. +func (miolr ManagedInstanceOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceOperationListResultIterator provides access to a complete listing of +// ManagedInstanceOperation values. +type ManagedInstanceOperationListResultIterator struct { + i int + page ManagedInstanceOperationListResultPage +} + +// NextWithContext 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 *ManagedInstanceOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceOperationListResultIterator) 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 ManagedInstanceOperationListResultIterator) Response() ManagedInstanceOperationListResult { + 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 ManagedInstanceOperationListResultIterator) Value() ManagedInstanceOperation { + if !iter.page.NotDone() { + return ManagedInstanceOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceOperationListResultIterator type. +func NewManagedInstanceOperationListResultIterator(page ManagedInstanceOperationListResultPage) ManagedInstanceOperationListResultIterator { + return ManagedInstanceOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miolr ManagedInstanceOperationListResult) IsEmpty() bool { + return miolr.Value == nil || len(*miolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miolr ManagedInstanceOperationListResult) hasNextLink() bool { + return miolr.NextLink != nil && len(*miolr.NextLink) != 0 +} + +// managedInstanceOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miolr ManagedInstanceOperationListResult) managedInstanceOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miolr.NextLink))) +} + +// ManagedInstanceOperationListResultPage contains a page of ManagedInstanceOperation values. +type ManagedInstanceOperationListResultPage struct { + fn func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error) + miolr ManagedInstanceOperationListResult +} + +// NextWithContext 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 *ManagedInstanceOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miolr) + if err != nil { + return err + } + page.miolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceOperationListResultPage) NotDone() bool { + return !page.miolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceOperationListResultPage) Response() ManagedInstanceOperationListResult { + return page.miolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceOperationListResultPage) Values() []ManagedInstanceOperation { + if page.miolr.IsEmpty() { + return nil + } + return *page.miolr.Value +} + +// Creates a new instance of the ManagedInstanceOperationListResultPage type. +func NewManagedInstanceOperationListResultPage(cur ManagedInstanceOperationListResult, getNextPage func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error)) ManagedInstanceOperationListResultPage { + return ManagedInstanceOperationListResultPage{ + fn: getNextPage, + miolr: cur, + } +} + +// ManagedInstanceOperationParametersPair the parameters of a managed instance operation. +type ManagedInstanceOperationParametersPair struct { + // CurrentParameters - READ-ONLY; The current parameters. + CurrentParameters *UpsertManagedServerOperationParameters `json:"currentParameters,omitempty"` + // RequestedParameters - READ-ONLY; The requested parameters. + RequestedParameters *UpsertManagedServerOperationParameters `json:"requestedParameters,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationParametersPair. +func (miopp ManagedInstanceOperationParametersPair) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceOperationProperties the properties of a managed instance operation. +type ManagedInstanceOperationProperties struct { + // ManagedInstanceName - READ-ONLY; The name of the managed instance the operation is being performed on. + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` + // OperationParameters - READ-ONLY; The operation parameters. + OperationParameters *ManagedInstanceOperationParametersPair `json:"operationParameters,omitempty"` + // OperationSteps - READ-ONLY; The operation steps. + OperationSteps *ManagedInstanceOperationSteps `json:"operationSteps,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationProperties. +func (miop ManagedInstanceOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceOperationSteps the steps of a managed instance operation. +type ManagedInstanceOperationSteps struct { + // TotalSteps - READ-ONLY; The total number of operation steps. + TotalSteps *string `json:"totalSteps,omitempty"` + // CurrentStep - READ-ONLY; The number of current operation steps. + CurrentStep *int32 `json:"currentStep,omitempty"` + // StepsList - READ-ONLY; The operation steps list. + StepsList *[]UpsertManagedServerOperationStep `json:"stepsList,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationSteps. +func (mios ManagedInstanceOperationSteps) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePairInfo pairs of Managed Instances in the failover group. +type ManagedInstancePairInfo struct { + // PrimaryManagedInstanceID - Id of Primary Managed Instance in pair. + PrimaryManagedInstanceID *string `json:"primaryManagedInstanceId,omitempty"` + // PartnerManagedInstanceID - Id of Partner Managed Instance in pair. + PartnerManagedInstanceID *string `json:"partnerManagedInstanceId,omitempty"` +} + +// ManagedInstancePecProperty a private endpoint connection under a managed instance +type ManagedInstancePecProperty struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Properties - READ-ONLY; Private endpoint connection properties + Properties *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePecProperty. +func (mipp ManagedInstancePecProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnectionProperties properties of a private endpoint connection. +type ManagedInstancePrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *ManagedInstancePrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. + PrivateLinkServiceConnectionState *ManagedInstancePrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the Private Endpoint Connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionProperties. +func (mipecp ManagedInstancePrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mipecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = mipecp.PrivateEndpoint + } + if mipecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = mipecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointProperty ... +type ManagedInstancePrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// ManagedInstancePrivateLinkServiceConnectionStateProperty ... +type ManagedInstancePrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The private link service connection description. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkServiceConnectionStateProperty. +func (miplscsp ManagedInstancePrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miplscsp.Status != nil { + objectMap["status"] = miplscsp.Status + } + if miplscsp.Description != nil { + objectMap["description"] = miplscsp.Description + } + return json.Marshal(objectMap) +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // ProvisioningState - READ-ONLY; Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1Deleting', 'ProvisioningState1Updating', 'ProvisioningState1Unknown', 'ProvisioningState1Succeeded', 'ProvisioningState1Failed' + ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` + // ManagedInstanceCreateMode - Specifies the mode of database creation. + // + // Default: Regular instance creation. + // + // Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: 'ManagedServerCreateModeDefault', 'ManagedServerCreateModePointInTimeRestore' + ManagedInstanceCreateMode ManagedServerCreateMode `json:"managedInstanceCreateMode,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the managed instance. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // AdministratorLogin - Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for managed instance creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // SubnetID - Subnet resource ID for the managed instance. + SubnetID *string `json:"subnetId,omitempty"` + // State - READ-ONLY; The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Possible values include: 'ManagedInstanceLicenseTypeLicenseIncluded', 'ManagedInstanceLicenseTypeBasePrice' + LicenseType ManagedInstanceLicenseType `json:"licenseType,omitempty"` + // VCores - The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - Storage size in GB. Minimum value: 32. Maximum value: 8192. Increments of 32 GB allowed only. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` + // Collation - Collation of the managed instance. + Collation *string `json:"collation,omitempty"` + // DNSZone - READ-ONLY; The Dns Zone that the managed instance is in. + DNSZone *string `json:"dnsZone,omitempty"` + // DNSZonePartner - The resource id of another managed instance whose DNS zone this managed instance will share after creation. + DNSZonePartner *string `json:"dnsZonePartner,omitempty"` + // PublicDataEndpointEnabled - Whether or not the public data endpoint is enabled. + PublicDataEndpointEnabled *bool `json:"publicDataEndpointEnabled,omitempty"` + // SourceManagedInstanceID - The resource identifier of the source managed instance associated with create operation of this instance. + SourceManagedInstanceID *string `json:"sourceManagedInstanceId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // ProxyOverride - Connection type used for connecting to the instance. Possible values include: 'ManagedInstanceProxyOverrideProxy', 'ManagedInstanceProxyOverrideRedirect', 'ManagedInstanceProxyOverrideDefault' + ProxyOverride ManagedInstanceProxyOverride `json:"proxyOverride,omitempty"` + // TimezoneID - Id of the timezone. Allowed values are timezones supported by Windows. + // Windows keeps details on supported timezones, including the id, in registry under + // KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. + // You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM sys.time_zone_info. + // List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. + // An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". + TimezoneID *string `json:"timezoneId,omitempty"` + // InstancePoolID - The Id of the instance pool this managed server belongs to. + InstancePoolID *string `json:"instancePoolId,omitempty"` + // MaintenanceConfigurationID - Specifies maintenance configuration id to apply to this managed instance. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections on a managed instance. + PrivateEndpointConnections *[]ManagedInstancePecProperty `json:"privateEndpointConnections,omitempty"` + // MinimalTLSVersion - Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2' + MinimalTLSVersion *string `json:"minimalTlsVersion,omitempty"` + // StorageAccountType - The storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). Possible values include: 'GRS', 'LRS', 'ZRS' + StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` + // ZoneRedundant - Whether or not the multi-az is enabled. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceProperties. +func (mip ManagedInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mip.ManagedInstanceCreateMode != "" { + objectMap["managedInstanceCreateMode"] = mip.ManagedInstanceCreateMode + } + if mip.AdministratorLogin != nil { + objectMap["administratorLogin"] = mip.AdministratorLogin + } + if mip.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = mip.AdministratorLoginPassword + } + if mip.SubnetID != nil { + objectMap["subnetId"] = mip.SubnetID + } + if mip.LicenseType != "" { + objectMap["licenseType"] = mip.LicenseType + } + if mip.VCores != nil { + objectMap["vCores"] = mip.VCores + } + if mip.StorageSizeInGB != nil { + objectMap["storageSizeInGB"] = mip.StorageSizeInGB + } + if mip.Collation != nil { + objectMap["collation"] = mip.Collation + } + if mip.DNSZonePartner != nil { + objectMap["dnsZonePartner"] = mip.DNSZonePartner + } + if mip.PublicDataEndpointEnabled != nil { + objectMap["publicDataEndpointEnabled"] = mip.PublicDataEndpointEnabled + } + if mip.SourceManagedInstanceID != nil { + objectMap["sourceManagedInstanceId"] = mip.SourceManagedInstanceID + } + if mip.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mip.RestorePointInTime + } + if mip.ProxyOverride != "" { + objectMap["proxyOverride"] = mip.ProxyOverride + } + if mip.TimezoneID != nil { + objectMap["timezoneId"] = mip.TimezoneID + } + if mip.InstancePoolID != nil { + objectMap["instancePoolId"] = mip.InstancePoolID + } + if mip.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = mip.MaintenanceConfigurationID + } + if mip.MinimalTLSVersion != nil { + objectMap["minimalTlsVersion"] = mip.MinimalTLSVersion + } + if mip.StorageAccountType != "" { + objectMap["storageAccountType"] = mip.StorageAccountType + } + if mip.ZoneRedundant != nil { + objectMap["zoneRedundant"] = mip.ZoneRedundant + } + return json.Marshal(objectMap) +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesCreateOrUpdateFuture.Result. +func (future *ManagedInstancesCreateOrUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.CreateOrUpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesDeleteFuture.Result. +func (future *ManagedInstancesDeleteFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancesFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesFailoverFuture.Result. +func (future *ManagedInstancesFailoverFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesUpdateFuture.Result. +func (future *ManagedInstancesUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.UpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceTdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceTdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceTdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceTdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceTdeCertificatesCreateFuture.Result. +func (future *ManagedInstanceTdeCertificatesCreateFuture) result(client ManagedInstanceTdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceTdeCertificatesCreateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceUpdate an update request for an Azure SQL Database managed instance. +type ManagedInstanceUpdate struct { + // Sku - Managed instance sku + Sku *Sku `json:"sku,omitempty"` + // Identity - Managed instance identity + Identity *ResourceIdentity `json:"identity,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceUpdate. +func (miu ManagedInstanceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miu.Sku != nil { + objectMap["sku"] = miu.Sku + } + if miu.Identity != nil { + objectMap["identity"] = miu.Identity + } + if miu.ManagedInstanceProperties != nil { + objectMap["properties"] = miu.ManagedInstanceProperties + } + if miu.Tags != nil { + objectMap["tags"] = miu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceUpdate struct. +func (miu *ManagedInstanceUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + miu.Sku = &sku + } + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + miu.Identity = &identity + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + miu.ManagedInstanceProperties = &managedInstanceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + miu.Tags = tags + } + } + } + + return nil +} + +// ManagedInstanceVcoresCapability the managed instance virtual cores capability. +type ManagedInstanceVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // IncludedMaxSize - READ-ONLY; Included size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedStorageSizes - READ-ONLY; Storage size ranges. + SupportedStorageSizes *[]MaxSizeRangeCapability `json:"supportedStorageSizes,omitempty"` + // InstancePoolSupported - READ-ONLY; True if this service objective is supported for managed instances in an instance pool. + InstancePoolSupported *bool `json:"instancePoolSupported,omitempty"` + // StandaloneSupported - READ-ONLY; True if this service objective is supported for standalone managed instances. + StandaloneSupported *bool `json:"standaloneSupported,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVcoresCapability. +func (mivc ManagedInstanceVcoresCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceVersionCapability the managed instance capability +type ManagedInstanceVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported managed instance editions. + SupportedEditions *[]ManagedInstanceEditionCapability `json:"supportedEditions,omitempty"` + // SupportedInstancePoolEditions - READ-ONLY; The list of supported instance pool editions. + SupportedInstancePoolEditions *[]InstancePoolEditionCapability `json:"supportedInstancePoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVersionCapability. +func (mivc ManagedInstanceVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceVulnerabilityAssessment a managed instance vulnerability assessment. +type ManagedInstanceVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // ManagedInstanceVulnerabilityAssessmentProperties - Resource properties. + *ManagedInstanceVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessment. +func (miva ManagedInstanceVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miva.ManagedInstanceVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = miva.ManagedInstanceVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceVulnerabilityAssessment struct. +func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceVulnerabilityAssessmentProperties ManagedInstanceVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &managedInstanceVulnerabilityAssessmentProperties) + if err != nil { + return err + } + miva.ManagedInstanceVulnerabilityAssessmentProperties = &managedInstanceVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miva.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceVulnerabilityAssessmentListResult a list of the ManagedInstance's vulnerability +// assessments. +type ManagedInstanceVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessmentListResult. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// ManagedInstanceVulnerabilityAssessment values. +type ManagedInstanceVulnerabilityAssessmentListResultIterator struct { + i int + page ManagedInstanceVulnerabilityAssessmentListResultPage +} + +// NextWithContext 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 *ManagedInstanceVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) 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 ManagedInstanceVulnerabilityAssessmentListResultIterator) Response() ManagedInstanceVulnerabilityAssessmentListResult { + 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 ManagedInstanceVulnerabilityAssessmentListResultIterator) Value() ManagedInstanceVulnerabilityAssessment { + if !iter.page.NotDone() { + return ManagedInstanceVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultIterator type. +func NewManagedInstanceVulnerabilityAssessmentListResultIterator(page ManagedInstanceVulnerabilityAssessmentListResultPage) ManagedInstanceVulnerabilityAssessmentListResultIterator { + return ManagedInstanceVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) IsEmpty() bool { + return mivalr.Value == nil || len(*mivalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) hasNextLink() bool { + return mivalr.NextLink != nil && len(*mivalr.NextLink) != 0 +} + +// managedInstanceVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) managedInstanceVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mivalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mivalr.NextLink))) +} + +// ManagedInstanceVulnerabilityAssessmentListResultPage contains a page of +// ManagedInstanceVulnerabilityAssessment values. +type ManagedInstanceVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error) + mivalr ManagedInstanceVulnerabilityAssessmentListResult +} + +// NextWithContext 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 *ManagedInstanceVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mivalr) + if err != nil { + return err + } + page.mivalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.mivalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Response() ManagedInstanceVulnerabilityAssessmentListResult { + return page.mivalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Values() []ManagedInstanceVulnerabilityAssessment { + if page.mivalr.IsEmpty() { + return nil + } + return *page.mivalr.Value +} + +// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultPage type. +func NewManagedInstanceVulnerabilityAssessmentListResultPage(cur ManagedInstanceVulnerabilityAssessmentListResult, getNextPage func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error)) ManagedInstanceVulnerabilityAssessmentListResultPage { + return ManagedInstanceVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + mivalr: cur, + } +} + +// ManagedInstanceVulnerabilityAssessmentProperties properties of a managed instance vulnerability +// assessment. +type ManagedInstanceVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has read and write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for +// monitoring and retrieving the results of a long-running operation. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture an abstraction for +// monitoring and retrieving the results of a long-running operation. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedServerSecurityAlertPoliciesClient) (ManagedServerSecurityAlertPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture) result(client ManagedServerSecurityAlertPoliciesClient) (mssap ManagedServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mssap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mssap.Response.Response, err = future.GetResult(sender); err == nil && mssap.Response.Response.StatusCode != http.StatusNoContent { + mssap, err = client.CreateOrUpdateResponder(mssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", mssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedServerSecurityAlertPolicy a managed server security alert policy. +type ManagedServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedServerSecurityAlertPolicy. +func (mssap ManagedServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mssap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = mssap.SecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedServerSecurityAlertPolicy struct. +func (mssap *ManagedServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + mssap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mssap.Type = &typeVar + } + } + } + + return nil +} + +// ManagedServerSecurityAlertPolicyListResult a list of the managed Server's security alert policies. +type ManagedServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedServerSecurityAlertPolicyListResult. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ManagedServerSecurityAlertPolicy values. +type ManagedServerSecurityAlertPolicyListResultIterator struct { + i int + page ManagedServerSecurityAlertPolicyListResultPage +} + +// NextWithContext 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 *ManagedServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedServerSecurityAlertPolicyListResultIterator) 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 ManagedServerSecurityAlertPolicyListResultIterator) Response() ManagedServerSecurityAlertPolicyListResult { + 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 ManagedServerSecurityAlertPolicyListResultIterator) Value() ManagedServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ManagedServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedServerSecurityAlertPolicyListResultIterator type. +func NewManagedServerSecurityAlertPolicyListResultIterator(page ManagedServerSecurityAlertPolicyListResultPage) ManagedServerSecurityAlertPolicyListResultIterator { + return ManagedServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) IsEmpty() bool { + return mssaplr.Value == nil || len(*mssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) hasNextLink() bool { + return mssaplr.NextLink != nil && len(*mssaplr.NextLink) != 0 +} + +// managedServerSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) managedServerSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mssaplr.NextLink))) +} + +// ManagedServerSecurityAlertPolicyListResultPage contains a page of ManagedServerSecurityAlertPolicy +// values. +type ManagedServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ManagedServerSecurityAlertPolicyListResult) (ManagedServerSecurityAlertPolicyListResult, error) + mssaplr ManagedServerSecurityAlertPolicyListResult +} + +// NextWithContext 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 *ManagedServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mssaplr) + if err != nil { + return err + } + page.mssaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.mssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedServerSecurityAlertPolicyListResultPage) Response() ManagedServerSecurityAlertPolicyListResult { + return page.mssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedServerSecurityAlertPolicyListResultPage) Values() []ManagedServerSecurityAlertPolicy { + if page.mssaplr.IsEmpty() { + return nil + } + return *page.mssaplr.Value +} + +// Creates a new instance of the ManagedServerSecurityAlertPolicyListResultPage type. +func NewManagedServerSecurityAlertPolicyListResultPage(cur ManagedServerSecurityAlertPolicyListResult, getNextPage func(context.Context, ManagedServerSecurityAlertPolicyListResult) (ManagedServerSecurityAlertPolicyListResult, error)) ManagedServerSecurityAlertPolicyListResultPage { + return ManagedServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + mssaplr: cur, + } +} + +// MaxSizeCapability the maximum size capability. +type MaxSizeCapability struct { + // Limit - READ-ONLY; The maximum size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'MaxSizeUnitMegabytes', 'MaxSizeUnitGigabytes', 'MaxSizeUnitTerabytes', 'MaxSizeUnitPetabytes' + Unit MaxSizeUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeCapability. +func (msc MaxSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MaxSizeRangeCapability the maximum size range capability. +type MaxSizeRangeCapability struct { + // MinValue - READ-ONLY; Minimum value. + MinValue *MaxSizeCapability `json:"minValue,omitempty"` + // MaxValue - READ-ONLY; Maximum value. + MaxValue *MaxSizeCapability `json:"maxValue,omitempty"` + // ScaleSize - READ-ONLY; Scale/step size for discrete values between the minimum value and the maximum value. + ScaleSize *MaxSizeCapability `json:"scaleSize,omitempty"` + // LogSize - READ-ONLY; Size of transaction log. + LogSize *LogSizeCapability `json:"logSize,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeRangeCapability. +func (msrc MaxSizeRangeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if msrc.Reason != nil { + objectMap["reason"] = msrc.Reason + } + return json.Marshal(objectMap) +} + +// Metric database metrics. +type Metric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time step to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for Metric. +func (mVar Metric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricAvailability a metric availability value. +type MetricAvailability struct { + // Retention - READ-ONLY; The length of retention for the database metric. + Retention *string `json:"retention,omitempty"` + // TimeGrain - READ-ONLY; The granularity of the database metric. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAvailability. +func (ma MetricAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinition a database metric definition. +type MetricDefinition struct { + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // PrimaryAggregationType - READ-ONLY; The primary aggregation type defining how metric values are displayed. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeCount', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeTotal' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // ResourceURI - READ-ONLY; The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' + Unit UnitDefinitionType `json:"unit,omitempty"` + // MetricAvailabilities - READ-ONLY; The list of database metric availabilities for the metric. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDefinition. +func (md MetricDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinitionListResult the response to a list database metric definitions request. +type MetricDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of metric definitions for the database. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricListResult the response to a list database metrics request. +type MetricListResult struct { + autorest.Response `json:"-"` + // Value - The list of metrics for the database. + Value *[]Metric `json:"value,omitempty"` +} + +// MetricName a database metric name. +type MetricName struct { + // Value - READ-ONLY; The name of the database metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - READ-ONLY; The friendly name of the database metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricName. +func (mn MetricName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricValue represents database metrics. +type MetricValue struct { + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricValue. +func (mv MetricValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MinCapacityCapability the min capacity capability +type MinCapacityCapability struct { + // Value - READ-ONLY; Min capacity value + Value *float64 `json:"value,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MinCapacityCapability. +func (mcc MinCapacityCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mcc.Reason != nil { + objectMap["reason"] = mcc.Reason + } + return json.Marshal(objectMap) +} + +// Name ARM Usage Name +type Name struct { + // Value - Usage name value + Value *string `json:"value,omitempty"` + // LocalizedValue - Usage name localized value. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// NetworkIsolationSettings contains the ARM resources for which to create private endpoint connection. +type NetworkIsolationSettings struct { + // StorageAccountResourceID - The resource id for the storage account used to store BACPAC file. If set, private endpoint connection will be created for the storage account. Must match storage account used for StorageUri parameter. + StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty"` + // SQLServerResourceID - The resource id for the SQL server which is the target of this request. If set, private endpoint connection will be created for the SQL server. Must match server which is target of the operation. + SQLServerResourceID *string `json:"sqlServerResourceId,omitempty"` +} + +// Operation SQL REST API operation definition. +type Operation struct { + // Name - READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The localized display information for this particular operation / action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. Possible values include: 'User', 'System' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - READ-ONLY; Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The localized friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationImpact the impact of an operation, both in absolute and relative terms. +type OperationImpact struct { + // Name - READ-ONLY; The name of the impact dimension. + Name *string `json:"name,omitempty"` + // Unit - READ-ONLY; The unit in which estimated impact to dimension is measured. + Unit *string `json:"unit,omitempty"` + // ChangeValueAbsolute - READ-ONLY; The absolute impact to dimension. + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - READ-ONLY; The relative impact to dimension (null if not applicable) + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationImpact. +func (oi OperationImpact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult result of the request to list SQL operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PartnerInfo partner server information for the failover group. +type PartnerInfo struct { + // ID - Resource identifier of the partner server. + ID *string `json:"id,omitempty"` + // Location - READ-ONLY; Geo location of the partner server. + Location *string `json:"location,omitempty"` + // ReplicationRole - READ-ONLY; Replication role of the partner server. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartnerInfo. +func (pi PartnerInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pi.ID != nil { + objectMap["id"] = pi.ID + } + return json.Marshal(objectMap) +} + +// PartnerRegionInfo partner region information for the failover group. +type PartnerRegionInfo struct { + // Location - Geo location of the partner managed instances. + Location *string `json:"location,omitempty"` + // ReplicationRole - READ-ONLY; Replication role of the partner managed instances. Possible values include: 'InstanceFailoverGroupReplicationRolePrimary', 'InstanceFailoverGroupReplicationRoleSecondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartnerRegionInfo. +func (pri PartnerRegionInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pri.Location != nil { + objectMap["location"] = pri.Location + } + return json.Marshal(objectMap) +} + +// PerformanceLevelCapability the performance level capability. +type PerformanceLevelCapability struct { + // Value - READ-ONLY; Performance level value. + Value *float64 `json:"value,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for PerformanceLevelCapability. +func (plc PerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections. +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionListResult. +func (peclr PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// NextWithContext 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 *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) 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 PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + 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 PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// NextWithContext 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 *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peclr) + if err != nil { + return err + } + page.peclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state of the private endpoint connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the private endpoint connection. Possible values include: 'PrivateEndpointProvisioningStateApproving', 'PrivateEndpointProvisioningStateReady', 'PrivateEndpointProvisioningStateDropping', 'PrivateEndpointProvisioningStateFailed', 'PrivateEndpointProvisioningStateRejecting' + ProvisioningState PrivateEndpointProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionRequestStatus contains the private endpoint connection requests status. +type PrivateEndpointConnectionRequestStatus struct { + // PrivateLinkServiceID - READ-ONLY; Resource id for which the private endpoint is created. + PrivateLinkServiceID *string `json:"privateLinkServiceId,omitempty"` + // PrivateEndpointConnectionName - READ-ONLY; The connection name for the private endpoint. + PrivateEndpointConnectionName *string `json:"privateEndpointConnectionName,omitempty"` + // Status - READ-ONLY; Status of this private endpoint connection. + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionRequestStatus. +func (pecrs PrivateEndpointConnectionRequestStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointProperty ... +type PrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // Properties - READ-ONLY; The private link resource group id. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceListResult. +func (plrlr PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResultIterator provides access to a complete listing of PrivateLinkResource +// values. +type PrivateLinkResourceListResultIterator struct { + i int + page PrivateLinkResourceListResultPage +} + +// NextWithContext 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 *PrivateLinkResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListResultIterator) 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 PrivateLinkResourceListResultIterator) Response() PrivateLinkResourceListResult { + 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 PrivateLinkResourceListResultIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListResultIterator type. +func NewPrivateLinkResourceListResultIterator(page PrivateLinkResourceListResultPage) PrivateLinkResourceListResultIterator { + return PrivateLinkResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrlr PrivateLinkResourceListResult) IsEmpty() bool { + return plrlr.Value == nil || len(*plrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrlr PrivateLinkResourceListResult) hasNextLink() bool { + return plrlr.NextLink != nil && len(*plrlr.NextLink) != 0 +} + +// privateLinkResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrlr PrivateLinkResourceListResult) privateLinkResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrlr.NextLink))) +} + +// PrivateLinkResourceListResultPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListResultPage struct { + fn func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error) + plrlr PrivateLinkResourceListResult +} + +// NextWithContext 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 *PrivateLinkResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrlr) + if err != nil { + return err + } + page.plrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListResultPage) NotDone() bool { + return !page.plrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListResultPage) Response() PrivateLinkResourceListResult { + return page.plrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListResultPage) Values() []PrivateLinkResource { + if page.plrlr.IsEmpty() { + return nil + } + return *page.plrlr.Value +} + +// Creates a new instance of the PrivateLinkResourceListResultPage type. +func NewPrivateLinkResourceListResultPage(cur PrivateLinkResourceListResult, getNextPage func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error)) PrivateLinkResourceListResultPage { + return PrivateLinkResourceListResultPage{ + fn: getNextPage, + plrlr: cur, + } +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionStateProperty ... +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. Possible values include: 'Approved', 'Pending', 'Rejected', 'Disconnected' + Status PrivateLinkServiceConnectionStateStatus `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The actions required for private link service connection. Possible values include: 'PrivateLinkServiceConnectionStateActionsRequireNone' + ActionsRequired PrivateLinkServiceConnectionStateActionsRequire `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. +func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscsp.Status != "" { + objectMap["status"] = plscsp.Status + } + if plscsp.Description != nil { + objectMap["description"] = plscsp.Description + } + return json.Marshal(objectMap) +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// QueryMetricInterval properties of a query metrics interval. +type QueryMetricInterval struct { + // IntervalStartTime - READ-ONLY; The start time for the metric interval (ISO-8601 format). + IntervalStartTime *string `json:"intervalStartTime,omitempty"` + // IntervalType - READ-ONLY; Interval type (length). Possible values include: 'PT1H', 'P1D' + IntervalType QueryTimeGrainType `json:"intervalType,omitempty"` + // ExecutionCount - READ-ONLY; Execution count of a query in this interval. + ExecutionCount *int64 `json:"executionCount,omitempty"` + // Metrics - List of metric objects for this interval + Metrics *[]QueryMetricProperties `json:"metrics,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryMetricInterval. +func (qmi QueryMetricInterval) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qmi.Metrics != nil { + objectMap["metrics"] = qmi.Metrics + } + return json.Marshal(objectMap) +} + +// QueryMetricProperties properties of a topquery metric in one interval. +type QueryMetricProperties struct { + // Name - READ-ONLY; The name information for the metric. + Name *string `json:"name,omitempty"` + // DisplayName - READ-ONLY; The UI appropriate name for the metric. + DisplayName *string `json:"displayName,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'Percentage', 'KB', 'Microseconds', 'Count' + Unit QueryMetricUnitType `json:"unit,omitempty"` + // Value - READ-ONLY; The value of the metric. + Value *float64 `json:"value,omitempty"` + // Min - READ-ONLY; Metric value when min() aggregate function is used over the interval. + Min *float64 `json:"min,omitempty"` + // Max - READ-ONLY; Metric value when max() aggregate function is used over the interval. + Max *float64 `json:"max,omitempty"` + // Avg - READ-ONLY; Metric value when avg() aggregate function is used over the interval. + Avg *float64 `json:"avg,omitempty"` + // Sum - READ-ONLY; Metric value when sum() aggregate function is used over the interval. + Sum *float64 `json:"sum,omitempty"` + // Stdev - READ-ONLY; Metric value when stdev aggregate function is used over the interval. + Stdev *float64 `json:"stdev,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryMetricProperties. +func (qmp QueryMetricProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// QueryStatisticsProperties properties of a query execution statistics. +type QueryStatisticsProperties struct { + // DatabaseName - READ-ONLY; Database name of the database in which this query was executed. + DatabaseName *string `json:"databaseName,omitempty"` + // QueryID - READ-ONLY; Unique query id (unique within one database). + QueryID *string `json:"queryId,omitempty"` + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *string `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *string `json:"endTime,omitempty"` + // Intervals - List of intervals with appropriate metric data + Intervals *[]QueryMetricInterval `json:"intervals,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryStatisticsProperties. +func (qsp QueryStatisticsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qsp.Intervals != nil { + objectMap["intervals"] = qsp.Intervals + } + return json.Marshal(objectMap) +} + +// ReadScaleCapability the read scale capability. +type ReadScaleCapability struct { + // MaxNumberOfReplicas - READ-ONLY; The maximum number of read scale replicas. + MaxNumberOfReplicas *int32 `json:"maxNumberOfReplicas,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReadScaleCapability. +func (rsc ReadScaleCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsc.Reason != nil { + objectMap["reason"] = rsc.Reason + } + return json.Marshal(objectMap) +} + +// RecommendedElasticPool represents a recommended elastic pool. +type RecommendedElasticPool struct { + autorest.Response `json:"-"` + // RecommendedElasticPoolProperties - The properties representing the resource. + *RecommendedElasticPoolProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedElasticPool. +func (rep RecommendedElasticPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rep.RecommendedElasticPoolProperties != nil { + objectMap["properties"] = rep.RecommendedElasticPoolProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecommendedElasticPool struct. +func (rep *RecommendedElasticPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recommendedElasticPoolProperties RecommendedElasticPoolProperties + err = json.Unmarshal(*v, &recommendedElasticPoolProperties) + if err != nil { + return err + } + rep.RecommendedElasticPoolProperties = &recommendedElasticPoolProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rep.Type = &typeVar + } + } + } + + return nil +} + +// RecommendedElasticPoolListMetricsResult represents the response to a list recommended elastic pool +// metrics request. +type RecommendedElasticPoolListMetricsResult struct { + autorest.Response `json:"-"` + // Value - The list of recommended elastic pools metrics. + Value *[]RecommendedElasticPoolMetric `json:"value,omitempty"` +} + +// RecommendedElasticPoolListResult represents the response to a list recommended elastic pool request. +type RecommendedElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - The list of recommended elastic pools hosted in the server. + Value *[]RecommendedElasticPool `json:"value,omitempty"` +} + +// RecommendedElasticPoolMetric represents recommended elastic pool metric. +type RecommendedElasticPoolMetric struct { + // DateTime - The time of metric (ISO8601 format). + DateTime *date.Time `json:"dateTime,omitempty"` + // Dtu - Gets or sets the DTUs (Database Transaction Units). See https://azure.microsoft.com/documentation/articles/sql-database-what-is-a-dtu/ + Dtu *float64 `json:"dtu,omitempty"` + // SizeGB - Gets or sets size in gigabytes. + SizeGB *float64 `json:"sizeGB,omitempty"` +} + +// RecommendedElasticPoolProperties represents the properties of a recommended elastic pool. +type RecommendedElasticPoolProperties struct { + // DatabaseEdition - READ-ONLY; The edition of the recommended elastic pool. The ElasticPoolEdition enumeration contains all the valid editions. Possible values include: 'Basic', 'Standard', 'Premium', 'GeneralPurpose', 'BusinessCritical' + DatabaseEdition ElasticPoolEdition `json:"databaseEdition,omitempty"` + // Dtu - The DTU for the recommended elastic pool. + Dtu *float64 `json:"dtu,omitempty"` + // DatabaseDtuMin - The minimum DTU for the database. + DatabaseDtuMin *float64 `json:"databaseDtuMin,omitempty"` + // DatabaseDtuMax - The maximum DTU for the database. + DatabaseDtuMax *float64 `json:"databaseDtuMax,omitempty"` + // StorageMB - Gets storage size in megabytes. + StorageMB *float64 `json:"storageMB,omitempty"` + // ObservationPeriodStart - READ-ONLY; The observation period start (ISO8601 format). + ObservationPeriodStart *date.Time `json:"observationPeriodStart,omitempty"` + // ObservationPeriodEnd - READ-ONLY; The observation period start (ISO8601 format). + ObservationPeriodEnd *date.Time `json:"observationPeriodEnd,omitempty"` + // MaxObservedDtu - READ-ONLY; Gets maximum observed DTU. + MaxObservedDtu *float64 `json:"maxObservedDtu,omitempty"` + // MaxObservedStorageMB - READ-ONLY; Gets maximum observed storage in megabytes. + MaxObservedStorageMB *float64 `json:"maxObservedStorageMB,omitempty"` + // Databases - READ-ONLY; The list of databases in this pool. Expanded property + Databases *[]TrackedResource `json:"databases,omitempty"` + // Metrics - READ-ONLY; The list of databases housed in the server. Expanded property + Metrics *[]RecommendedElasticPoolMetric `json:"metrics,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedElasticPoolProperties. +func (repp RecommendedElasticPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if repp.Dtu != nil { + objectMap["dtu"] = repp.Dtu + } + if repp.DatabaseDtuMin != nil { + objectMap["databaseDtuMin"] = repp.DatabaseDtuMin + } + if repp.DatabaseDtuMax != nil { + objectMap["databaseDtuMax"] = repp.DatabaseDtuMax + } + if repp.StorageMB != nil { + objectMap["storageMB"] = repp.StorageMB + } + return json.Marshal(objectMap) +} + +// RecommendedIndex represents a database recommended index. +type RecommendedIndex struct { + // RecommendedIndexProperties - READ-ONLY; The properties representing the resource. + *RecommendedIndexProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedIndex. +func (ri RecommendedIndex) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecommendedIndex struct. +func (ri *RecommendedIndex) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recommendedIndexProperties RecommendedIndexProperties + err = json.Unmarshal(*v, &recommendedIndexProperties) + if err != nil { + return err + } + ri.RecommendedIndexProperties = &recommendedIndexProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ri.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ri.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ri.Type = &typeVar + } + } + } + + return nil +} + +// RecommendedIndexProperties represents the properties of a database recommended index. +type RecommendedIndexProperties struct { + // Action - READ-ONLY; 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 - READ-ONLY; The current recommendation state. Possible values include: 'RecommendedIndexStateActive', 'RecommendedIndexStatePending', 'RecommendedIndexStateExecuting', 'RecommendedIndexStateVerifying', 'RecommendedIndexStatePendingRevert', 'RecommendedIndexStateReverting', 'RecommendedIndexStateReverted', 'RecommendedIndexStateIgnored', 'RecommendedIndexStateExpired', 'RecommendedIndexStateBlocked', 'RecommendedIndexStateSuccess' + State RecommendedIndexState `json:"state,omitempty"` + // Created - READ-ONLY; The UTC datetime showing when this resource was created (ISO8601 format). + Created *date.Time `json:"created,omitempty"` + // LastModified - READ-ONLY; The UTC datetime of when was this resource last changed (ISO8601 format). + LastModified *date.Time `json:"lastModified,omitempty"` + // IndexType - READ-ONLY; The type of index (CLUSTERED, NONCLUSTERED, COLUMNSTORE, CLUSTERED COLUMNSTORE). Possible values include: 'CLUSTERED', 'NONCLUSTERED', 'COLUMNSTORE', 'CLUSTEREDCOLUMNSTORE' + IndexType RecommendedIndexType `json:"indexType,omitempty"` + // Schema - READ-ONLY; The schema where table to build index over resides + Schema *string `json:"schema,omitempty"` + // Table - READ-ONLY; The table on which to build index. + Table *string `json:"table,omitempty"` + // Columns - READ-ONLY; Columns over which to build index + Columns *[]string `json:"columns,omitempty"` + // IncludedColumns - READ-ONLY; The list of column names to be included in the index + IncludedColumns *[]string `json:"includedColumns,omitempty"` + // IndexScript - READ-ONLY; The full build index script + IndexScript *string `json:"indexScript,omitempty"` + // EstimatedImpact - READ-ONLY; The estimated impact of doing recommended index action. + EstimatedImpact *[]OperationImpact `json:"estimatedImpact,omitempty"` + // ReportedImpact - READ-ONLY; The values reported after index action is complete. + ReportedImpact *[]OperationImpact `json:"reportedImpact,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedIndexProperties. +func (rip RecommendedIndexProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableDatabase a recoverable database +type RecoverableDatabase struct { + autorest.Response `json:"-"` + // RecoverableDatabaseProperties - The properties of a recoverable database + *RecoverableDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableDatabase. +func (rd RecoverableDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.RecoverableDatabaseProperties != nil { + objectMap["properties"] = rd.RecoverableDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableDatabase struct. +func (rd *RecoverableDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recoverableDatabaseProperties RecoverableDatabaseProperties + err = json.Unmarshal(*v, &recoverableDatabaseProperties) + if err != nil { + return err + } + rd.RecoverableDatabaseProperties = &recoverableDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rd.Type = &typeVar + } + } + } + + return nil +} + +// RecoverableDatabaseListResult the response to a list recoverable databases request +type RecoverableDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - A list of recoverable databases + Value *[]RecoverableDatabase `json:"value,omitempty"` +} + +// RecoverableDatabaseProperties the properties of a recoverable database +type RecoverableDatabaseProperties struct { + // Edition - READ-ONLY; The edition of the database + Edition *string `json:"edition,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - READ-ONLY; The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // LastAvailableBackupDate - READ-ONLY; The last available backup date of the database (ISO8601 format) + LastAvailableBackupDate *date.Time `json:"lastAvailableBackupDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableDatabaseProperties. +func (rdp RecoverableDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableManagedDatabase a recoverable managed database resource. +type RecoverableManagedDatabase struct { + autorest.Response `json:"-"` + // RecoverableManagedDatabaseProperties - Resource properties. + *RecoverableManagedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabase. +func (rmd RecoverableManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmd.RecoverableManagedDatabaseProperties != nil { + objectMap["properties"] = rmd.RecoverableManagedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableManagedDatabase struct. +func (rmd *RecoverableManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recoverableManagedDatabaseProperties RecoverableManagedDatabaseProperties + err = json.Unmarshal(*v, &recoverableManagedDatabaseProperties) + if err != nil { + return err + } + rmd.RecoverableManagedDatabaseProperties = &recoverableManagedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmd.Type = &typeVar + } + } + } + + return nil +} + +// RecoverableManagedDatabaseListResult a list of recoverable managed databases. +type RecoverableManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RecoverableManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabaseListResult. +func (rmdlr RecoverableManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableManagedDatabaseListResultIterator provides access to a complete listing of +// RecoverableManagedDatabase values. +type RecoverableManagedDatabaseListResultIterator struct { + i int + page RecoverableManagedDatabaseListResultPage +} + +// NextWithContext 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 *RecoverableManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RecoverableManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RecoverableManagedDatabaseListResultIterator) 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 RecoverableManagedDatabaseListResultIterator) Response() RecoverableManagedDatabaseListResult { + 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 RecoverableManagedDatabaseListResultIterator) Value() RecoverableManagedDatabase { + if !iter.page.NotDone() { + return RecoverableManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RecoverableManagedDatabaseListResultIterator type. +func NewRecoverableManagedDatabaseListResultIterator(page RecoverableManagedDatabaseListResultPage) RecoverableManagedDatabaseListResultIterator { + return RecoverableManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rmdlr RecoverableManagedDatabaseListResult) IsEmpty() bool { + return rmdlr.Value == nil || len(*rmdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rmdlr RecoverableManagedDatabaseListResult) hasNextLink() bool { + return rmdlr.NextLink != nil && len(*rmdlr.NextLink) != 0 +} + +// recoverableManagedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rmdlr RecoverableManagedDatabaseListResult) recoverableManagedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rmdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rmdlr.NextLink))) +} + +// RecoverableManagedDatabaseListResultPage contains a page of RecoverableManagedDatabase values. +type RecoverableManagedDatabaseListResultPage struct { + fn func(context.Context, RecoverableManagedDatabaseListResult) (RecoverableManagedDatabaseListResult, error) + rmdlr RecoverableManagedDatabaseListResult +} + +// NextWithContext 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 *RecoverableManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rmdlr) + if err != nil { + return err + } + page.rmdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *RecoverableManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RecoverableManagedDatabaseListResultPage) NotDone() bool { + return !page.rmdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RecoverableManagedDatabaseListResultPage) Response() RecoverableManagedDatabaseListResult { + return page.rmdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RecoverableManagedDatabaseListResultPage) Values() []RecoverableManagedDatabase { + if page.rmdlr.IsEmpty() { + return nil + } + return *page.rmdlr.Value +} + +// Creates a new instance of the RecoverableManagedDatabaseListResultPage type. +func NewRecoverableManagedDatabaseListResultPage(cur RecoverableManagedDatabaseListResult, getNextPage func(context.Context, RecoverableManagedDatabaseListResult) (RecoverableManagedDatabaseListResult, error)) RecoverableManagedDatabaseListResultPage { + return RecoverableManagedDatabaseListResultPage{ + fn: getNextPage, + rmdlr: cur, + } +} + +// RecoverableManagedDatabaseProperties the recoverable managed database's properties. +type RecoverableManagedDatabaseProperties struct { + // LastAvailableBackupDate - READ-ONLY; The last available backup date. + LastAvailableBackupDate *string `json:"lastAvailableBackupDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabaseProperties. +func (rmdp RecoverableManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLink represents a database replication link. +type ReplicationLink struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Location of the server that contains this firewall rule. + Location *string `json:"location,omitempty"` + // ReplicationLinkProperties - The properties representing the resource. + *ReplicationLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLink. +func (rl ReplicationLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rl.ReplicationLinkProperties != nil { + objectMap["properties"] = rl.ReplicationLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ReplicationLink struct. +func (rl *ReplicationLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rl.Location = &location + } + case "properties": + if v != nil { + var replicationLinkProperties ReplicationLinkProperties + err = json.Unmarshal(*v, &replicationLinkProperties) + if err != nil { + return err + } + rl.ReplicationLinkProperties = &replicationLinkProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rl.Type = &typeVar + } + } + } + + return nil +} + +// ReplicationLinkListResult represents the response to a List database replication link request. +type ReplicationLinkListResult struct { + autorest.Response `json:"-"` + // Value - The list of database replication links housed in the database. + Value *[]ReplicationLink `json:"value,omitempty"` +} + +// ReplicationLinkProperties represents the properties of a database replication link. +type ReplicationLinkProperties struct { + // IsTerminationAllowed - READ-ONLY; Legacy value indicating whether termination is allowed. Currently always returns true. + IsTerminationAllowed *bool `json:"isTerminationAllowed,omitempty"` + // ReplicationMode - READ-ONLY; Replication mode of this replication link. + ReplicationMode *string `json:"replicationMode,omitempty"` + // PartnerServer - READ-ONLY; The name of the server hosting the partner database. + PartnerServer *string `json:"partnerServer,omitempty"` + // PartnerDatabase - READ-ONLY; The name of the partner database. + PartnerDatabase *string `json:"partnerDatabase,omitempty"` + // PartnerLocation - READ-ONLY; The Azure Region of the partner database. + PartnerLocation *string `json:"partnerLocation,omitempty"` + // Role - READ-ONLY; The role of the database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + Role ReplicationRole `json:"role,omitempty"` + // PartnerRole - READ-ONLY; The role of the partner database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + PartnerRole ReplicationRole `json:"partnerRole,omitempty"` + // StartTime - READ-ONLY; The start time for the replication link. + StartTime *date.Time `json:"startTime,omitempty"` + // PercentComplete - READ-ONLY; The percentage of seeding complete for the replication link. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ReplicationState - READ-ONLY; The replication state for the replication link. Possible values include: 'PENDING', 'SEEDING', 'CATCHUP', 'SUSPENDED' + ReplicationState ReplicationState `json:"replicationState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLinkProperties. +func (rlp ReplicationLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLinksFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ReplicationLinksFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksFailoverAllowDataLossFuture.Result. +func (future *ReplicationLinksFailoverAllowDataLossFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") + return + } + ar.Response = future.Response() + return +} + +// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ReplicationLinksFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksFailoverFuture.Result. +func (future *ReplicationLinksFailoverFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ReplicationLinksUnlinkFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReplicationLinksUnlinkFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksUnlinkFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksUnlinkFuture.Result. +func (future *ReplicationLinksUnlinkFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksUnlinkFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksUnlinkFuture") + return + } + ar.Response = future.Response() + return +} + +// Resource ARM resource. +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceIdentity azure Active Directory identity configuration for a resource. +type ResourceIdentity struct { + // PrincipalID - READ-ONLY; The Azure Active Directory principal id. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned' + Type IdentityType `json:"type,omitempty"` + // TenantID - READ-ONLY; The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceIdentity. +func (ri ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ri.Type != "" { + objectMap["type"] = ri.Type + } + return json.Marshal(objectMap) +} + +// ResourceMoveDefinition contains the information necessary to perform a resource move (rename). +type ResourceMoveDefinition struct { + // ID - The target ID for the resource + ID *string `json:"id,omitempty"` +} + +// RestorableDroppedDatabase a restorable dropped database +type RestorableDroppedDatabase struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // RestorableDroppedDatabaseProperties - The properties of a restorable dropped database + *RestorableDroppedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabase. +func (rdd RestorableDroppedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdd.RestorableDroppedDatabaseProperties != nil { + objectMap["properties"] = rdd.RestorableDroppedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDroppedDatabase struct. +func (rdd *RestorableDroppedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdd.Location = &location + } + case "properties": + if v != nil { + var restorableDroppedDatabaseProperties RestorableDroppedDatabaseProperties + err = json.Unmarshal(*v, &restorableDroppedDatabaseProperties) + if err != nil { + return err + } + rdd.RestorableDroppedDatabaseProperties = &restorableDroppedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rdd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rdd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rdd.Type = &typeVar + } + } + } + + return nil +} + +// RestorableDroppedDatabaseListResult the response to a list restorable dropped databases request +type RestorableDroppedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - A list of restorable dropped databases + Value *[]RestorableDroppedDatabase `json:"value,omitempty"` +} + +// RestorableDroppedDatabaseProperties the properties of a restorable dropped database +type RestorableDroppedDatabaseProperties struct { + // DatabaseName - READ-ONLY; The name of the database + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - READ-ONLY; The edition of the database + Edition *string `json:"edition,omitempty"` + // MaxSizeBytes - READ-ONLY; The max size in bytes of the database + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - READ-ONLY; The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format) + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - READ-ONLY; The deletion date of the database (ISO8601 format) + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore date of the database (ISO8601 format) + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabaseProperties. +func (rddp RestorableDroppedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableDroppedManagedDatabase a restorable dropped managed database resource. +type RestorableDroppedManagedDatabase struct { + autorest.Response `json:"-"` + // RestorableDroppedManagedDatabaseProperties - Resource properties. + *RestorableDroppedManagedDatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedManagedDatabase. +func (rdmd RestorableDroppedManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdmd.RestorableDroppedManagedDatabaseProperties != nil { + objectMap["properties"] = rdmd.RestorableDroppedManagedDatabaseProperties + } + if rdmd.Location != nil { + objectMap["location"] = rdmd.Location + } + if rdmd.Tags != nil { + objectMap["tags"] = rdmd.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDroppedManagedDatabase struct. +func (rdmd *RestorableDroppedManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableDroppedManagedDatabaseProperties RestorableDroppedManagedDatabaseProperties + err = json.Unmarshal(*v, &restorableDroppedManagedDatabaseProperties) + if err != nil { + return err + } + rdmd.RestorableDroppedManagedDatabaseProperties = &restorableDroppedManagedDatabaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdmd.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rdmd.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rdmd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rdmd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rdmd.Type = &typeVar + } + } + } + + return nil +} + +// RestorableDroppedManagedDatabaseListResult a list of restorable dropped managed databases. +type RestorableDroppedManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RestorableDroppedManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedManagedDatabaseListResult. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableDroppedManagedDatabaseListResultIterator provides access to a complete listing of +// RestorableDroppedManagedDatabase values. +type RestorableDroppedManagedDatabaseListResultIterator struct { + i int + page RestorableDroppedManagedDatabaseListResultPage +} + +// NextWithContext 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 *RestorableDroppedManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RestorableDroppedManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RestorableDroppedManagedDatabaseListResultIterator) 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 RestorableDroppedManagedDatabaseListResultIterator) Response() RestorableDroppedManagedDatabaseListResult { + 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 RestorableDroppedManagedDatabaseListResultIterator) Value() RestorableDroppedManagedDatabase { + if !iter.page.NotDone() { + return RestorableDroppedManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RestorableDroppedManagedDatabaseListResultIterator type. +func NewRestorableDroppedManagedDatabaseListResultIterator(page RestorableDroppedManagedDatabaseListResultPage) RestorableDroppedManagedDatabaseListResultIterator { + return RestorableDroppedManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) IsEmpty() bool { + return rdmdlr.Value == nil || len(*rdmdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) hasNextLink() bool { + return rdmdlr.NextLink != nil && len(*rdmdlr.NextLink) != 0 +} + +// restorableDroppedManagedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) restorableDroppedManagedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rdmdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rdmdlr.NextLink))) +} + +// RestorableDroppedManagedDatabaseListResultPage contains a page of RestorableDroppedManagedDatabase +// values. +type RestorableDroppedManagedDatabaseListResultPage struct { + fn func(context.Context, RestorableDroppedManagedDatabaseListResult) (RestorableDroppedManagedDatabaseListResult, error) + rdmdlr RestorableDroppedManagedDatabaseListResult +} + +// NextWithContext 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 *RestorableDroppedManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rdmdlr) + if err != nil { + return err + } + page.rdmdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *RestorableDroppedManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RestorableDroppedManagedDatabaseListResultPage) NotDone() bool { + return !page.rdmdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RestorableDroppedManagedDatabaseListResultPage) Response() RestorableDroppedManagedDatabaseListResult { + return page.rdmdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RestorableDroppedManagedDatabaseListResultPage) Values() []RestorableDroppedManagedDatabase { + if page.rdmdlr.IsEmpty() { + return nil + } + return *page.rdmdlr.Value +} + +// Creates a new instance of the RestorableDroppedManagedDatabaseListResultPage type. +func NewRestorableDroppedManagedDatabaseListResultPage(cur RestorableDroppedManagedDatabaseListResult, getNextPage func(context.Context, RestorableDroppedManagedDatabaseListResult) (RestorableDroppedManagedDatabaseListResult, error)) RestorableDroppedManagedDatabaseListResultPage { + return RestorableDroppedManagedDatabaseListResultPage{ + fn: getNextPage, + rdmdlr: cur, + } +} + +// RestorableDroppedManagedDatabaseProperties the restorable dropped managed database's properties. +type RestorableDroppedManagedDatabaseProperties struct { + // DatabaseName - READ-ONLY; The name of the database. + DatabaseName *string `json:"databaseName,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - READ-ONLY; The deletion date of the database (ISO8601 format). + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore date of the database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedManagedDatabaseProperties. +func (rdmdp RestorableDroppedManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePoint database restore points. +type RestorePoint struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // RestorePointProperties - Resource properties. + *RestorePointProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePoint. +func (rp RestorePoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RestorePointProperties != nil { + objectMap["properties"] = rp.RestorePointProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorePoint struct. +func (rp *RestorePoint) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rp.Location = &location + } + case "properties": + if v != nil { + var restorePointProperties RestorePointProperties + err = json.Unmarshal(*v, &restorePointProperties) + if err != nil { + return err + } + rp.RestorePointProperties = &restorePointProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rp.Type = &typeVar + } + } + } + + return nil +} + +// RestorePointListResult a list of long term retention backups. +type RestorePointListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RestorePoint `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePointListResult. +func (rplr RestorePointListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePointProperties properties of a database restore point +type RestorePointProperties struct { + // RestorePointType - READ-ONLY; The type of restore point. Possible values include: 'CONTINUOUS', 'DISCRETE' + RestorePointType RestorePointType `json:"restorePointType,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest time to which this database can be restored + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // RestorePointCreationDate - READ-ONLY; The time the backup was taken + RestorePointCreationDate *date.Time `json:"restorePointCreationDate,omitempty"` + // RestorePointLabel - READ-ONLY; The label of restore point for backup request by user + RestorePointLabel *string `json:"restorePointLabel,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePointProperties. +func (rpp RestorePointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RestorePointsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(RestorePointsClient) (RestorePoint, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *RestorePointsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for RestorePointsCreateFuture.Result. +func (future *RestorePointsCreateFuture) result(client RestorePointsClient) (rp RestorePoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + rp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.RestorePointsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rp.Response.Response, err = future.GetResult(sender); err == nil && rp.Response.Response.StatusCode != http.StatusNoContent { + rp, err = client.CreateResponder(rp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", rp.Response.Response, "Failure responding to request") + } + } + return +} + +// SecurityAlertPolicyProperties properties of a security alert policy. +type SecurityAlertPolicyProperties struct { + // State - Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: 'SecurityAlertPolicyStateNew', 'SecurityAlertPolicyStateEnabled', 'SecurityAlertPolicyStateDisabled' + State SecurityAlertPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action + DisabledAlerts *[]string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies an array of e-mail addresses to which the alert is sent. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. + EmailAccountAdmins *bool `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // CreationTime - READ-ONLY; Specifies the UTC creation time of the policy. + CreationTime *date.Time `json:"creationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityAlertPolicyProperties. +func (sapp SecurityAlertPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sapp.State != "" { + objectMap["state"] = sapp.State + } + if sapp.DisabledAlerts != nil { + objectMap["disabledAlerts"] = sapp.DisabledAlerts + } + if sapp.EmailAddresses != nil { + objectMap["emailAddresses"] = sapp.EmailAddresses + } + if sapp.EmailAccountAdmins != nil { + objectMap["emailAccountAdmins"] = sapp.EmailAccountAdmins + } + if sapp.StorageEndpoint != nil { + objectMap["storageEndpoint"] = sapp.StorageEndpoint + } + if sapp.StorageAccountAccessKey != nil { + objectMap["storageAccountAccessKey"] = sapp.StorageAccountAccessKey + } + if sapp.RetentionDays != nil { + objectMap["retentionDays"] = sapp.RetentionDays + } + return json.Marshal(objectMap) +} + +// SensitivityLabel a sensitivity label. +type SensitivityLabel struct { + autorest.Response `json:"-"` + // SensitivityLabelProperties - Resource properties. + *SensitivityLabelProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabel. +func (sl SensitivityLabel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sl.SensitivityLabelProperties != nil { + objectMap["properties"] = sl.SensitivityLabelProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SensitivityLabel struct. +func (sl *SensitivityLabel) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var sensitivityLabelProperties SensitivityLabelProperties + err = json.Unmarshal(*v, &sensitivityLabelProperties) + if err != nil { + return err + } + sl.SensitivityLabelProperties = &sensitivityLabelProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sl.Type = &typeVar + } + } + } + + return nil +} + +// SensitivityLabelListResult a list of sensitivity labels. +type SensitivityLabelListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SensitivityLabel `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabelListResult. +func (sllr SensitivityLabelListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SensitivityLabelListResultIterator provides access to a complete listing of SensitivityLabel values. +type SensitivityLabelListResultIterator struct { + i int + page SensitivityLabelListResultPage +} + +// NextWithContext 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 *SensitivityLabelListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SensitivityLabelListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SensitivityLabelListResultIterator) 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 SensitivityLabelListResultIterator) Response() SensitivityLabelListResult { + 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 SensitivityLabelListResultIterator) Value() SensitivityLabel { + if !iter.page.NotDone() { + return SensitivityLabel{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SensitivityLabelListResultIterator type. +func NewSensitivityLabelListResultIterator(page SensitivityLabelListResultPage) SensitivityLabelListResultIterator { + return SensitivityLabelListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sllr SensitivityLabelListResult) IsEmpty() bool { + return sllr.Value == nil || len(*sllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sllr SensitivityLabelListResult) hasNextLink() bool { + return sllr.NextLink != nil && len(*sllr.NextLink) != 0 +} + +// sensitivityLabelListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sllr SensitivityLabelListResult) sensitivityLabelListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sllr.NextLink))) +} + +// SensitivityLabelListResultPage contains a page of SensitivityLabel values. +type SensitivityLabelListResultPage struct { + fn func(context.Context, SensitivityLabelListResult) (SensitivityLabelListResult, error) + sllr SensitivityLabelListResult +} + +// NextWithContext 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 *SensitivityLabelListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sllr) + if err != nil { + return err + } + page.sllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SensitivityLabelListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SensitivityLabelListResultPage) NotDone() bool { + return !page.sllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SensitivityLabelListResultPage) Response() SensitivityLabelListResult { + return page.sllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SensitivityLabelListResultPage) Values() []SensitivityLabel { + if page.sllr.IsEmpty() { + return nil + } + return *page.sllr.Value +} + +// Creates a new instance of the SensitivityLabelListResultPage type. +func NewSensitivityLabelListResultPage(cur SensitivityLabelListResult, getNextPage func(context.Context, SensitivityLabelListResult) (SensitivityLabelListResult, error)) SensitivityLabelListResultPage { + return SensitivityLabelListResultPage{ + fn: getNextPage, + sllr: cur, + } +} + +// SensitivityLabelProperties properties of a sensitivity label. +type SensitivityLabelProperties struct { + // LabelName - The label name. + LabelName *string `json:"labelName,omitempty"` + // LabelID - The label ID. + LabelID *string `json:"labelId,omitempty"` + // InformationType - The information type. + InformationType *string `json:"informationType,omitempty"` + // InformationTypeID - The information type ID. + InformationTypeID *string `json:"informationTypeId,omitempty"` + // IsDisabled - READ-ONLY; Is sensitivity recommendation disabled. Applicable for recommended sensitivity label only. Specifies whether the sensitivity recommendation on this column is disabled (dismissed) or not. + IsDisabled *bool `json:"isDisabled,omitempty"` + // Rank - Possible values include: 'SensitivityLabelRankNone', 'SensitivityLabelRankLow', 'SensitivityLabelRankMedium', 'SensitivityLabelRankHigh', 'SensitivityLabelRankCritical' + Rank SensitivityLabelRank `json:"rank,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabelProperties. +func (slp SensitivityLabelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if slp.LabelName != nil { + objectMap["labelName"] = slp.LabelName + } + if slp.LabelID != nil { + objectMap["labelId"] = slp.LabelID + } + if slp.InformationType != nil { + objectMap["informationType"] = slp.InformationType + } + if slp.InformationTypeID != nil { + objectMap["informationTypeId"] = slp.InformationTypeID + } + if slp.Rank != "" { + objectMap["rank"] = slp.Rank + } + return json.Marshal(objectMap) +} + +// Server an Azure SQL Database server. +type Server struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the server. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Kind - READ-ONLY; Kind of sql server. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ServerProperties - Resource properties. + *ServerProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Identity != nil { + objectMap["identity"] = s.Identity + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Server struct. +func (s *Server) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + s.Kind = &kind + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServerAutomaticTuning server-level Automatic Tuning. +type ServerAutomaticTuning struct { + autorest.Response `json:"-"` + // AutomaticTuningServerProperties - Resource properties. + *AutomaticTuningServerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAutomaticTuning. +func (sat ServerAutomaticTuning) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sat.AutomaticTuningServerProperties != nil { + objectMap["properties"] = sat.AutomaticTuningServerProperties + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var automaticTuningServerProperties AutomaticTuningServerProperties + err = json.Unmarshal(*v, &automaticTuningServerProperties) + if err != nil { + return err + } + sat.AutomaticTuningServerProperties = &automaticTuningServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sat.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sat.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sat.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADAdministrator azure Active Directory administrator. +type ServerAzureADAdministrator struct { + autorest.Response `json:"-"` + // AdministratorProperties - Resource properties. + *AdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAzureADAdministrator. +func (saaa ServerAzureADAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if saaa.AdministratorProperties != nil { + objectMap["properties"] = saaa.AdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAzureADAdministrator struct. +func (saaa *ServerAzureADAdministrator) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var administratorProperties AdministratorProperties + err = json.Unmarshal(*v, &administratorProperties) + if err != nil { + return err + } + saaa.AdministratorProperties = &administratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + saaa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + saaa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + saaa.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerAzureADAdministratorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADAdministratorsClient) (ServerAzureADAdministrator, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADAdministratorsCreateOrUpdateFuture.Result. +func (future *ServerAzureADAdministratorsCreateOrUpdateFuture) result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + saaa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaa.Response.Response, err = future.GetResult(sender); err == nil && saaa.Response.Response.StatusCode != http.StatusNoContent { + saaa, err = client.CreateOrUpdateResponder(saaa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", saaa.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerAzureADAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerAzureADAdministratorsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADAdministratorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADAdministratorsDeleteFuture.Result. +func (future *ServerAzureADAdministratorsDeleteFuture) result(client ServerAzureADAdministratorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerAzureADOnlyAuthentication azure Active Directory only authentication. +type ServerAzureADOnlyAuthentication struct { + autorest.Response `json:"-"` + // AzureADOnlyAuthProperties - Resource properties. + *AzureADOnlyAuthProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAzureADOnlyAuthentication. +func (saaoa ServerAzureADOnlyAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if saaoa.AzureADOnlyAuthProperties != nil { + objectMap["properties"] = saaoa.AzureADOnlyAuthProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAzureADOnlyAuthentication struct. +func (saaoa *ServerAzureADOnlyAuthentication) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var azureADOnlyAuthProperties AzureADOnlyAuthProperties + err = json.Unmarshal(*v, &azureADOnlyAuthProperties) + if err != nil { + return err + } + saaoa.AzureADOnlyAuthProperties = &azureADOnlyAuthProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + saaoa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + saaoa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + saaoa.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADOnlyAuthenticationsClient) (ServerAzureADOnlyAuthentication, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture.Result. +func (future *ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture) result(client ServerAzureADOnlyAuthenticationsClient) (saaoa ServerAzureADOnlyAuthentication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + saaoa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaoa.Response.Response, err = future.GetResult(sender); err == nil && saaoa.Response.Response.StatusCode != http.StatusNoContent { + saaoa, err = client.CreateOrUpdateResponder(saaoa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", saaoa.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerAzureADOnlyAuthenticationsDeleteFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerAzureADOnlyAuthenticationsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADOnlyAuthenticationsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADOnlyAuthenticationsDeleteFuture.Result. +func (future *ServerAzureADOnlyAuthenticationsDeleteFuture) result(client ServerAzureADOnlyAuthenticationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADOnlyAuthenticationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerBlobAuditingPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerBlobAuditingPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerBlobAuditingPoliciesClient) (ServerBlobAuditingPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerBlobAuditingPoliciesCreateOrUpdateFuture.Result. +func (future *ServerBlobAuditingPoliciesCreateOrUpdateFuture) result(client ServerBlobAuditingPoliciesClient) (sbap ServerBlobAuditingPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sbap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sbap.Response.Response, err = future.GetResult(sender); err == nil && sbap.Response.Response.StatusCode != http.StatusNoContent { + sbap, err = client.CreateOrUpdateResponder(sbap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", sbap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerBlobAuditingPolicy a server blob auditing policy. +type ServerBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ServerBlobAuditingPolicyProperties - Resource properties. + *ServerBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerBlobAuditingPolicy. +func (sbap ServerBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sbap.ServerBlobAuditingPolicyProperties != nil { + objectMap["properties"] = sbap.ServerBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerBlobAuditingPolicy struct. +func (sbap *ServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverBlobAuditingPolicyProperties ServerBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &serverBlobAuditingPolicyProperties) + if err != nil { + return err + } + sbap.ServerBlobAuditingPolicyProperties = &serverBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sbap.Type = &typeVar + } + } + } + + return nil +} + +// ServerBlobAuditingPolicyListResult a list of server auditing settings. +type ServerBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerBlobAuditingPolicyListResult. +func (sbaplr ServerBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ServerBlobAuditingPolicy values. +type ServerBlobAuditingPolicyListResultIterator struct { + i int + page ServerBlobAuditingPolicyListResultPage +} + +// NextWithContext 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 *ServerBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerBlobAuditingPolicyListResultIterator) 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 ServerBlobAuditingPolicyListResultIterator) Response() ServerBlobAuditingPolicyListResult { + 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 ServerBlobAuditingPolicyListResultIterator) Value() ServerBlobAuditingPolicy { + if !iter.page.NotDone() { + return ServerBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerBlobAuditingPolicyListResultIterator type. +func NewServerBlobAuditingPolicyListResultIterator(page ServerBlobAuditingPolicyListResultPage) ServerBlobAuditingPolicyListResultIterator { + return ServerBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sbaplr ServerBlobAuditingPolicyListResult) IsEmpty() bool { + return sbaplr.Value == nil || len(*sbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sbaplr ServerBlobAuditingPolicyListResult) hasNextLink() bool { + return sbaplr.NextLink != nil && len(*sbaplr.NextLink) != 0 +} + +// serverBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sbaplr ServerBlobAuditingPolicyListResult) serverBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sbaplr.NextLink))) +} + +// ServerBlobAuditingPolicyListResultPage contains a page of ServerBlobAuditingPolicy values. +type ServerBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ServerBlobAuditingPolicyListResult) (ServerBlobAuditingPolicyListResult, error) + sbaplr ServerBlobAuditingPolicyListResult +} + +// NextWithContext 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 *ServerBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sbaplr) + if err != nil { + return err + } + page.sbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.sbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerBlobAuditingPolicyListResultPage) Response() ServerBlobAuditingPolicyListResult { + return page.sbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerBlobAuditingPolicyListResultPage) Values() []ServerBlobAuditingPolicy { + if page.sbaplr.IsEmpty() { + return nil + } + return *page.sbaplr.Value +} + +// Creates a new instance of the ServerBlobAuditingPolicyListResultPage type. +func NewServerBlobAuditingPolicyListResultPage(cur ServerBlobAuditingPolicyListResult, getNextPage func(context.Context, ServerBlobAuditingPolicyListResult) (ServerBlobAuditingPolicyListResult, error)) ServerBlobAuditingPolicyListResultPage { + return ServerBlobAuditingPolicyListResultPage{ + fn: getNextPage, + sbaplr: cur, + } +} + +// ServerBlobAuditingPolicyProperties properties of a server blob auditing policy. +type ServerBlobAuditingPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` +} + +// ServerCommunicationLink server communication link. +type ServerCommunicationLink struct { + autorest.Response `json:"-"` + // ServerCommunicationLinkProperties - The properties of resource. + *ServerCommunicationLinkProperties `json:"properties,omitempty"` + // Location - READ-ONLY; Communication link location. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; Communication link kind. This property is used for Azure Portal metadata. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerCommunicationLink. +func (scl ServerCommunicationLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scl.ServerCommunicationLinkProperties != nil { + objectMap["properties"] = scl.ServerCommunicationLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerCommunicationLink struct. +func (scl *ServerCommunicationLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverCommunicationLinkProperties ServerCommunicationLinkProperties + err = json.Unmarshal(*v, &serverCommunicationLinkProperties) + if err != nil { + return err + } + scl.ServerCommunicationLinkProperties = &serverCommunicationLinkProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scl.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + scl.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scl.Type = &typeVar + } + } + } + + return nil +} + +// ServerCommunicationLinkListResult a list of server communication links. +type ServerCommunicationLinkListResult struct { + autorest.Response `json:"-"` + // Value - The list of server communication links. + Value *[]ServerCommunicationLink `json:"value,omitempty"` +} + +// ServerCommunicationLinkProperties the properties of a server communication link. +type ServerCommunicationLinkProperties struct { + // State - READ-ONLY; The state. + State *string `json:"state,omitempty"` + // PartnerServer - The name of the partner server. + PartnerServer *string `json:"partnerServer,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerCommunicationLinkProperties. +func (sclp ServerCommunicationLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sclp.PartnerServer != nil { + objectMap["partnerServer"] = sclp.PartnerServer + } + return json.Marshal(objectMap) +} + +// ServerCommunicationLinksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerCommunicationLinksCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerCommunicationLinksClient) (ServerCommunicationLink, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerCommunicationLinksCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerCommunicationLinksCreateOrUpdateFuture.Result. +func (future *ServerCommunicationLinksCreateOrUpdateFuture) result(client ServerCommunicationLinksClient) (scl ServerCommunicationLink, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + scl.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if scl.Response.Response, err = future.GetResult(sender); err == nil && scl.Response.Response.StatusCode != http.StatusNoContent { + scl, err = client.CreateOrUpdateResponder(scl.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", scl.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerConnectionPolicy a server secure connection policy. +type ServerConnectionPolicy struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // ServerConnectionPolicyProperties - The properties of the server secure connection policy. + *ServerConnectionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerConnectionPolicy. +func (scp ServerConnectionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.ServerConnectionPolicyProperties != nil { + objectMap["properties"] = scp.ServerConnectionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerConnectionPolicy struct. +func (scp *ServerConnectionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + scp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scp.Location = &location + } + case "properties": + if v != nil { + var serverConnectionPolicyProperties ServerConnectionPolicyProperties + err = json.Unmarshal(*v, &serverConnectionPolicyProperties) + if err != nil { + return err + } + scp.ServerConnectionPolicyProperties = &serverConnectionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scp.Type = &typeVar + } + } + } + + return nil +} + +// ServerConnectionPolicyProperties the properties of a server secure connection policy. +type ServerConnectionPolicyProperties struct { + // ConnectionType - The server connection type. Possible values include: 'ServerConnectionTypeDefault', 'ServerConnectionTypeProxy', 'ServerConnectionTypeRedirect' + ConnectionType ServerConnectionType `json:"connectionType,omitempty"` +} + +// ServerDNSAlias a server DNS alias. +type ServerDNSAlias struct { + autorest.Response `json:"-"` + // ServerDNSAliasProperties - Resource properties. + *ServerDNSAliasProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDNSAlias. +func (sda ServerDNSAlias) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sda.ServerDNSAliasProperties != nil { + objectMap["properties"] = sda.ServerDNSAliasProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerDNSAlias struct. +func (sda *ServerDNSAlias) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverDNSAliasProperties ServerDNSAliasProperties + err = json.Unmarshal(*v, &serverDNSAliasProperties) + if err != nil { + return err + } + sda.ServerDNSAliasProperties = &serverDNSAliasProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sda.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sda.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sda.Type = &typeVar + } + } + } + + return nil +} + +// ServerDNSAliasAcquisition a server DNS alias acquisition request. +type ServerDNSAliasAcquisition struct { + // OldServerDNSAliasID - The id of the server alias that will be acquired to point to this server instead. + OldServerDNSAliasID *string `json:"oldServerDnsAliasId,omitempty"` +} + +// ServerDNSAliasesAcquireFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerDNSAliasesAcquireFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDNSAliasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDNSAliasesAcquireFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDNSAliasesAcquireFuture.Result. +func (future *ServerDNSAliasesAcquireFuture) result(client ServerDNSAliasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesAcquireFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerDNSAliasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerDNSAliasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDNSAliasesClient) (ServerDNSAlias, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDNSAliasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDNSAliasesCreateOrUpdateFuture.Result. +func (future *ServerDNSAliasesCreateOrUpdateFuture) result(client ServerDNSAliasesClient) (sda ServerDNSAlias, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sda.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sda.Response.Response, err = future.GetResult(sender); err == nil && sda.Response.Response.StatusCode != http.StatusNoContent { + sda, err = client.CreateOrUpdateResponder(sda.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", sda.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerDNSAliasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerDNSAliasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDNSAliasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDNSAliasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDNSAliasesDeleteFuture.Result. +func (future *ServerDNSAliasesDeleteFuture) result(client ServerDNSAliasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerDNSAliasListResult a list of server DNS aliases. +type ServerDNSAliasListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerDNSAlias `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDNSAliasListResult. +func (sdalr ServerDNSAliasListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerDNSAliasListResultIterator provides access to a complete listing of ServerDNSAlias values. +type ServerDNSAliasListResultIterator struct { + i int + page ServerDNSAliasListResultPage +} + +// NextWithContext 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 *ServerDNSAliasListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerDNSAliasListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerDNSAliasListResultIterator) 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 ServerDNSAliasListResultIterator) Response() ServerDNSAliasListResult { + 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 ServerDNSAliasListResultIterator) Value() ServerDNSAlias { + if !iter.page.NotDone() { + return ServerDNSAlias{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerDNSAliasListResultIterator type. +func NewServerDNSAliasListResultIterator(page ServerDNSAliasListResultPage) ServerDNSAliasListResultIterator { + return ServerDNSAliasListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdalr ServerDNSAliasListResult) IsEmpty() bool { + return sdalr.Value == nil || len(*sdalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdalr ServerDNSAliasListResult) hasNextLink() bool { + return sdalr.NextLink != nil && len(*sdalr.NextLink) != 0 +} + +// serverDNSAliasListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdalr ServerDNSAliasListResult) serverDNSAliasListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdalr.NextLink))) +} + +// ServerDNSAliasListResultPage contains a page of ServerDNSAlias values. +type ServerDNSAliasListResultPage struct { + fn func(context.Context, ServerDNSAliasListResult) (ServerDNSAliasListResult, error) + sdalr ServerDNSAliasListResult +} + +// NextWithContext 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 *ServerDNSAliasListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdalr) + if err != nil { + return err + } + page.sdalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerDNSAliasListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerDNSAliasListResultPage) NotDone() bool { + return !page.sdalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerDNSAliasListResultPage) Response() ServerDNSAliasListResult { + return page.sdalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerDNSAliasListResultPage) Values() []ServerDNSAlias { + if page.sdalr.IsEmpty() { + return nil + } + return *page.sdalr.Value +} + +// Creates a new instance of the ServerDNSAliasListResultPage type. +func NewServerDNSAliasListResultPage(cur ServerDNSAliasListResult, getNextPage func(context.Context, ServerDNSAliasListResult) (ServerDNSAliasListResult, error)) ServerDNSAliasListResultPage { + return ServerDNSAliasListResultPage{ + fn: getNextPage, + sdalr: cur, + } +} + +// ServerDNSAliasProperties properties of a server DNS alias. +type ServerDNSAliasProperties struct { + // AzureDNSRecord - READ-ONLY; The fully qualified DNS record for alias + AzureDNSRecord *string `json:"azureDnsRecord,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDNSAliasProperties. +func (sdap ServerDNSAliasProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerInfo server info for the server trust group. +type ServerInfo struct { + // ServerID - Server Id. + ServerID *string `json:"serverId,omitempty"` +} + +// ServerKey a server key. +type ServerKey struct { + autorest.Response `json:"-"` + // Kind - Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // ServerKeyProperties - Resource properties. + *ServerKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKey. +func (sk ServerKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sk.Kind != nil { + objectMap["kind"] = sk.Kind + } + if sk.ServerKeyProperties != nil { + objectMap["properties"] = sk.ServerKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerKey struct. +func (sk *ServerKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + sk.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sk.Location = &location + } + case "properties": + if v != nil { + var serverKeyProperties ServerKeyProperties + err = json.Unmarshal(*v, &serverKeyProperties) + if err != nil { + return err + } + sk.ServerKeyProperties = &serverKeyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sk.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sk.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sk.Type = &typeVar + } + } + } + + return nil +} + +// ServerKeyListResult a list of server keys. +type ServerKeyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerKey `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKeyListResult. +func (sklr ServerKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerKeyListResultIterator provides access to a complete listing of ServerKey values. +type ServerKeyListResultIterator struct { + i int + page ServerKeyListResultPage +} + +// NextWithContext 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 *ServerKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerKeyListResultIterator) 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 ServerKeyListResultIterator) Response() ServerKeyListResult { + 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 ServerKeyListResultIterator) Value() ServerKey { + if !iter.page.NotDone() { + return ServerKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerKeyListResultIterator type. +func NewServerKeyListResultIterator(page ServerKeyListResultPage) ServerKeyListResultIterator { + return ServerKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sklr ServerKeyListResult) IsEmpty() bool { + return sklr.Value == nil || len(*sklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sklr ServerKeyListResult) hasNextLink() bool { + return sklr.NextLink != nil && len(*sklr.NextLink) != 0 +} + +// serverKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sklr ServerKeyListResult) serverKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sklr.NextLink))) +} + +// ServerKeyListResultPage contains a page of ServerKey values. +type ServerKeyListResultPage struct { + fn func(context.Context, ServerKeyListResult) (ServerKeyListResult, error) + sklr ServerKeyListResult +} + +// NextWithContext 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 *ServerKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sklr) + if err != nil { + return err + } + page.sklr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerKeyListResultPage) NotDone() bool { + return !page.sklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerKeyListResultPage) Response() ServerKeyListResult { + return page.sklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerKeyListResultPage) Values() []ServerKey { + if page.sklr.IsEmpty() { + return nil + } + return *page.sklr.Value +} + +// Creates a new instance of the ServerKeyListResultPage type. +func NewServerKeyListResultPage(cur ServerKeyListResult, getNextPage func(context.Context, ServerKeyListResult) (ServerKeyListResult, error)) ServerKeyListResultPage { + return ServerKeyListResultPage{ + fn: getNextPage, + sklr: cur, + } +} + +// ServerKeyProperties properties for a server key execution. +type ServerKeyProperties struct { + // Subregion - READ-ONLY; Subregion of the server key. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyType - The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServiceManaged', 'AzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - The server key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKeyProperties. +func (skp ServerKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if skp.ServerKeyType != "" { + objectMap["serverKeyType"] = skp.ServerKeyType + } + if skp.URI != nil { + objectMap["uri"] = skp.URI + } + if skp.Thumbprint != nil { + objectMap["thumbprint"] = skp.Thumbprint + } + if skp.CreationDate != nil { + objectMap["creationDate"] = skp.CreationDate + } + return json.Marshal(objectMap) +} + +// ServerKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerKeysCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerKeysClient) (ServerKey, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerKeysCreateOrUpdateFuture.Result. +func (future *ServerKeysCreateOrUpdateFuture) result(client ServerKeysClient) (sk ServerKey, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sk.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sk.Response.Response, err = future.GetResult(sender); err == nil && sk.Response.Response.StatusCode != http.StatusNoContent { + sk, err = client.CreateOrUpdateResponder(sk.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", sk.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerKeysDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerKeysClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerKeysDeleteFuture.Result. +func (future *ServerKeysDeleteFuture) result(client ServerKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Server `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerListResult. +func (slr ServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// NextWithContext 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 *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerListResultIterator) 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 ServerListResultIterator) Response() ServerListResult { + 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 ServerListResultIterator) Value() Server { + if !iter.page.NotDone() { + return Server{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerListResultIterator type. +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return ServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServerListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer(ctx context.Context) (*http.Request, error) { + if !slr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(context.Context, ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// NextWithContext 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 *ServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerListResultPage) Response() ServerListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerListResultPage) Values() []Server { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServerListResultPage type. +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return ServerListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServerPrivateEndpointConnection a private endpoint connection under a server +type ServerPrivateEndpointConnection struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Properties - READ-ONLY; Private endpoint connection properties + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerPrivateEndpointConnection. +func (spec ServerPrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - Administrator username for the server. Once created it cannot be changed. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - The version of the server. + Version *string `json:"version,omitempty"` + // State - READ-ONLY; The state of the server. + State *string `json:"state,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections on a server + PrivateEndpointConnections *[]ServerPrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // MinimalTLSVersion - Minimal TLS version. Allowed values: '1.0', '1.1', '1.2' + MinimalTLSVersion *string `json:"minimalTlsVersion,omitempty"` + // PublicNetworkAccess - Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: 'ServerPublicNetworkAccessEnabled', 'ServerPublicNetworkAccessDisabled' + PublicNetworkAccess ServerPublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerProperties. +func (sp ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AdministratorLogin != nil { + objectMap["administratorLogin"] = sp.AdministratorLogin + } + if sp.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword + } + if sp.Version != nil { + objectMap["version"] = sp.Version + } + if sp.MinimalTLSVersion != nil { + objectMap["minimalTlsVersion"] = sp.MinimalTLSVersion + } + if sp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = sp.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersCreateOrUpdateFuture.Result. +func (future *ServersCreateOrUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateOrUpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerSecurityAlertPoliciesClient) (ServerSecurityAlertPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerSecurityAlertPoliciesCreateOrUpdateFuture.Result. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) result(client ServerSecurityAlertPoliciesClient) (ssap ServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ssap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ssap.Response.Response, err = future.GetResult(sender); err == nil && ssap.Response.Response.StatusCode != http.StatusNoContent { + ssap, err = client.CreateOrUpdateResponder(ssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", ssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerSecurityAlertPolicy a server security alert policy. +type ServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicy. +func (ssap ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ssap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = ssap.SecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerSecurityAlertPolicy struct. +func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + ssap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ssap.Type = &typeVar + } + } + } + + return nil +} + +// ServersImportDatabaseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersImportDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (ImportExportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersImportDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersImportDatabaseFuture.Result. +func (future *ServersImportDatabaseFuture) result(client ServersClient) (ieor ImportExportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersImportDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ImportDatabaseResponder(ieor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", ieor.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerTrustGroup a server trust group. +type ServerTrustGroup struct { + autorest.Response `json:"-"` + // ServerTrustGroupProperties - Resource properties. + *ServerTrustGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerTrustGroup. +func (stg ServerTrustGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stg.ServerTrustGroupProperties != nil { + objectMap["properties"] = stg.ServerTrustGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerTrustGroup struct. +func (stg *ServerTrustGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverTrustGroupProperties ServerTrustGroupProperties + err = json.Unmarshal(*v, &serverTrustGroupProperties) + if err != nil { + return err + } + stg.ServerTrustGroupProperties = &serverTrustGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + stg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + stg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + stg.Type = &typeVar + } + } + } + + return nil +} + +// ServerTrustGroupListResult a list of server trust groups. +type ServerTrustGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerTrustGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerTrustGroupListResult. +func (stglr ServerTrustGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerTrustGroupListResultIterator provides access to a complete listing of ServerTrustGroup values. +type ServerTrustGroupListResultIterator struct { + i int + page ServerTrustGroupListResultPage +} + +// NextWithContext 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 *ServerTrustGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerTrustGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerTrustGroupListResultIterator) 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 ServerTrustGroupListResultIterator) Response() ServerTrustGroupListResult { + 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 ServerTrustGroupListResultIterator) Value() ServerTrustGroup { + if !iter.page.NotDone() { + return ServerTrustGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerTrustGroupListResultIterator type. +func NewServerTrustGroupListResultIterator(page ServerTrustGroupListResultPage) ServerTrustGroupListResultIterator { + return ServerTrustGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (stglr ServerTrustGroupListResult) IsEmpty() bool { + return stglr.Value == nil || len(*stglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (stglr ServerTrustGroupListResult) hasNextLink() bool { + return stglr.NextLink != nil && len(*stglr.NextLink) != 0 +} + +// serverTrustGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (stglr ServerTrustGroupListResult) serverTrustGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !stglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(stglr.NextLink))) +} + +// ServerTrustGroupListResultPage contains a page of ServerTrustGroup values. +type ServerTrustGroupListResultPage struct { + fn func(context.Context, ServerTrustGroupListResult) (ServerTrustGroupListResult, error) + stglr ServerTrustGroupListResult +} + +// NextWithContext 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 *ServerTrustGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.stglr) + if err != nil { + return err + } + page.stglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerTrustGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerTrustGroupListResultPage) NotDone() bool { + return !page.stglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerTrustGroupListResultPage) Response() ServerTrustGroupListResult { + return page.stglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerTrustGroupListResultPage) Values() []ServerTrustGroup { + if page.stglr.IsEmpty() { + return nil + } + return *page.stglr.Value +} + +// Creates a new instance of the ServerTrustGroupListResultPage type. +func NewServerTrustGroupListResultPage(cur ServerTrustGroupListResult, getNextPage func(context.Context, ServerTrustGroupListResult) (ServerTrustGroupListResult, error)) ServerTrustGroupListResultPage { + return ServerTrustGroupListResultPage{ + fn: getNextPage, + stglr: cur, + } +} + +// ServerTrustGroupProperties properties of a server trust group. +type ServerTrustGroupProperties struct { + // GroupMembers - Group members information for the server trust group. + GroupMembers *[]ServerInfo `json:"groupMembers,omitempty"` + // TrustScopes - Trust scope of the server trust group. + TrustScopes *[]string `json:"trustScopes,omitempty"` +} + +// ServerTrustGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerTrustGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerTrustGroupsClient) (ServerTrustGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerTrustGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerTrustGroupsCreateOrUpdateFuture.Result. +func (future *ServerTrustGroupsCreateOrUpdateFuture) result(client ServerTrustGroupsClient) (stg ServerTrustGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + stg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerTrustGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if stg.Response.Response, err = future.GetResult(sender); err == nil && stg.Response.Response.StatusCode != http.StatusNoContent { + stg, err = client.CreateOrUpdateResponder(stg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsCreateOrUpdateFuture", "Result", stg.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerTrustGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerTrustGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerTrustGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerTrustGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerTrustGroupsDeleteFuture.Result. +func (future *ServerTrustGroupsDeleteFuture) result(client ServerTrustGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerTrustGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerUpdate an update request for an Azure SQL Database server. +type ServerUpdate struct { + // ServerProperties - Resource properties. + *ServerProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerUpdate. +func (su ServerUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if su.ServerProperties != nil { + objectMap["properties"] = su.ServerProperties + } + if su.Tags != nil { + objectMap["tags"] = su.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerUpdate struct. +func (su *ServerUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + su.ServerProperties = &serverProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + su.Tags = tags + } + } + } + + return nil +} + +// ServerUsage represents server metrics. +type ServerUsage struct { + // Name - READ-ONLY; Name of the server usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - READ-ONLY; The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - READ-ONLY; The metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; The current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; The current limit of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units of the metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - READ-ONLY; The next reset time for the metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerUsage. +func (su ServerUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerUsageListResult represents the response to a list server metrics request. +type ServerUsageListResult struct { + autorest.Response `json:"-"` + // Value - The list of server metrics for the server. + Value *[]ServerUsage `json:"value,omitempty"` +} + +// ServerVersionCapability the server capability +type ServerVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - READ-ONLY; The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if svc.Reason != nil { + objectMap["reason"] = svc.Reason + } + return json.Marshal(objectMap) +} + +// ServerVulnerabilityAssessment a server vulnerability assessment. +type ServerVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // ServerVulnerabilityAssessmentProperties - Resource properties. + *ServerVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityAssessment. +func (sva ServerVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sva.ServerVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = sva.ServerVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerVulnerabilityAssessment struct. +func (sva *ServerVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverVulnerabilityAssessmentProperties ServerVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &serverVulnerabilityAssessmentProperties) + if err != nil { + return err + } + sva.ServerVulnerabilityAssessmentProperties = &serverVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sva.Type = &typeVar + } + } + } + + return nil +} + +// ServerVulnerabilityAssessmentListResult a list of the server's vulnerability assessments. +type ServerVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityAssessmentListResult. +func (svalr ServerVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// ServerVulnerabilityAssessment values. +type ServerVulnerabilityAssessmentListResultIterator struct { + i int + page ServerVulnerabilityAssessmentListResultPage +} + +// NextWithContext 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 *ServerVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerVulnerabilityAssessmentListResultIterator) 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 ServerVulnerabilityAssessmentListResultIterator) Response() ServerVulnerabilityAssessmentListResult { + 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 ServerVulnerabilityAssessmentListResultIterator) Value() ServerVulnerabilityAssessment { + if !iter.page.NotDone() { + return ServerVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerVulnerabilityAssessmentListResultIterator type. +func NewServerVulnerabilityAssessmentListResultIterator(page ServerVulnerabilityAssessmentListResultPage) ServerVulnerabilityAssessmentListResultIterator { + return ServerVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (svalr ServerVulnerabilityAssessmentListResult) IsEmpty() bool { + return svalr.Value == nil || len(*svalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (svalr ServerVulnerabilityAssessmentListResult) hasNextLink() bool { + return svalr.NextLink != nil && len(*svalr.NextLink) != 0 +} + +// serverVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (svalr ServerVulnerabilityAssessmentListResult) serverVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !svalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(svalr.NextLink))) +} + +// ServerVulnerabilityAssessmentListResultPage contains a page of ServerVulnerabilityAssessment values. +type ServerVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, ServerVulnerabilityAssessmentListResult) (ServerVulnerabilityAssessmentListResult, error) + svalr ServerVulnerabilityAssessmentListResult +} + +// NextWithContext 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 *ServerVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.svalr) + if err != nil { + return err + } + page.svalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.svalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerVulnerabilityAssessmentListResultPage) Response() ServerVulnerabilityAssessmentListResult { + return page.svalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerVulnerabilityAssessmentListResultPage) Values() []ServerVulnerabilityAssessment { + if page.svalr.IsEmpty() { + return nil + } + return *page.svalr.Value +} + +// Creates a new instance of the ServerVulnerabilityAssessmentListResultPage type. +func NewServerVulnerabilityAssessmentListResultPage(cur ServerVulnerabilityAssessmentListResult, getNextPage func(context.Context, ServerVulnerabilityAssessmentListResult) (ServerVulnerabilityAssessmentListResult, error)) ServerVulnerabilityAssessmentListResultPage { + return ServerVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + svalr: cur, + } +} + +// ServerVulnerabilityAssessmentProperties properties of a server Vulnerability Assessment. +type ServerVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has read and write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// ServiceObjective represents a database service objective. +type ServiceObjective struct { + autorest.Response `json:"-"` + // ServiceObjectiveProperties - Represents the properties of the resource. + *ServiceObjectiveProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjective. +func (so ServiceObjective) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if so.ServiceObjectiveProperties != nil { + objectMap["properties"] = so.ServiceObjectiveProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceObjective struct. +func (so *ServiceObjective) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceObjectiveProperties ServiceObjectiveProperties + err = json.Unmarshal(*v, &serviceObjectiveProperties) + if err != nil { + return err + } + so.ServiceObjectiveProperties = &serviceObjectiveProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + so.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + so.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + so.Type = &typeVar + } + } + } + + return nil +} + +// ServiceObjectiveCapability the service objectives capability. +type ServiceObjectiveCapability struct { + // ID - READ-ONLY; The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // Name - READ-ONLY; The service objective name. + Name *string `json:"name,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported maximum database sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // PerformanceLevel - READ-ONLY; The performance level. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the service objective. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // SupportedAutoPauseDelay - READ-ONLY; Supported time range for auto pause delay + SupportedAutoPauseDelay *AutoPauseDelayTimeRange `json:"supportedAutoPauseDelay,omitempty"` + // SupportedMinCapacities - READ-ONLY; List of supported min capacities + SupportedMinCapacities *[]MinCapacityCapability `json:"supportedMinCapacities,omitempty"` + // ComputeModel - READ-ONLY; The compute model + ComputeModel *string `json:"computeModel,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveCapability. +func (soc ServiceObjectiveCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if soc.Reason != nil { + objectMap["reason"] = soc.Reason + } + return json.Marshal(objectMap) +} + +// ServiceObjectiveListResult represents the response to a get database service objectives request. +type ServiceObjectiveListResult struct { + autorest.Response `json:"-"` + // Value - The list of database service objectives. + Value *[]ServiceObjective `json:"value,omitempty"` +} + +// ServiceObjectiveProperties represents the properties of a database service objective. +type ServiceObjectiveProperties struct { + // ServiceObjectiveName - READ-ONLY; The name for the service objective. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // IsDefault - READ-ONLY; Gets whether the service level objective is the default service objective. + IsDefault *bool `json:"isDefault,omitempty"` + // IsSystem - READ-ONLY; Gets whether the service level objective is a system service objective. + IsSystem *bool `json:"isSystem,omitempty"` + // Description - READ-ONLY; The description for the service level objective. + Description *string `json:"description,omitempty"` + // Enabled - READ-ONLY; Gets whether the service level objective is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveProperties. +func (sop ServiceObjectiveProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServiceTierAdvisor represents a Service Tier Advisor. +type ServiceTierAdvisor struct { + autorest.Response `json:"-"` + // ServiceTierAdvisorProperties - READ-ONLY; The properties representing the resource. + *ServiceTierAdvisorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceTierAdvisor. +func (sta ServiceTierAdvisor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceTierAdvisor struct. +func (sta *ServiceTierAdvisor) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceTierAdvisorProperties ServiceTierAdvisorProperties + err = json.Unmarshal(*v, &serviceTierAdvisorProperties) + if err != nil { + return err + } + sta.ServiceTierAdvisorProperties = &serviceTierAdvisorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sta.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sta.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sta.Type = &typeVar + } + } + } + + return nil +} + +// ServiceTierAdvisorListResult represents the response to a list service tier advisor request. +type ServiceTierAdvisorListResult struct { + autorest.Response `json:"-"` + // Value - The list of service tier advisors for specified database. + Value *[]ServiceTierAdvisor `json:"value,omitempty"` +} + +// ServiceTierAdvisorProperties represents the properties of a Service Tier Advisor. +type ServiceTierAdvisorProperties struct { + // ObservationPeriodStart - READ-ONLY; The observation period start (ISO8601 format). + ObservationPeriodStart *date.Time `json:"observationPeriodStart,omitempty"` + // ObservationPeriodEnd - READ-ONLY; The observation period start (ISO8601 format). + ObservationPeriodEnd *date.Time `json:"observationPeriodEnd,omitempty"` + // ActiveTimeRatio - READ-ONLY; The activeTimeRatio for service tier advisor. + ActiveTimeRatio *float64 `json:"activeTimeRatio,omitempty"` + // MinDtu - READ-ONLY; Gets or sets minDtu for service tier advisor. + MinDtu *float64 `json:"minDtu,omitempty"` + // AvgDtu - READ-ONLY; Gets or sets avgDtu for service tier advisor. + AvgDtu *float64 `json:"avgDtu,omitempty"` + // MaxDtu - READ-ONLY; Gets or sets maxDtu for service tier advisor. + MaxDtu *float64 `json:"maxDtu,omitempty"` + // MaxSizeInGB - READ-ONLY; Gets or sets maxSizeInGB for service tier advisor. + MaxSizeInGB *float64 `json:"maxSizeInGB,omitempty"` + // ServiceLevelObjectiveUsageMetrics - READ-ONLY; Gets or sets serviceLevelObjectiveUsageMetrics for the service tier advisor. + ServiceLevelObjectiveUsageMetrics *[]SloUsageMetric `json:"serviceLevelObjectiveUsageMetrics,omitempty"` + // CurrentServiceLevelObjective - READ-ONLY; Gets or sets currentServiceLevelObjective for service tier advisor. + CurrentServiceLevelObjective *string `json:"currentServiceLevelObjective,omitempty"` + // CurrentServiceLevelObjectiveID - READ-ONLY; Gets or sets currentServiceLevelObjectiveId for service tier advisor. + CurrentServiceLevelObjectiveID *uuid.UUID `json:"currentServiceLevelObjectiveId,omitempty"` + // UsageBasedRecommendationServiceLevelObjective - READ-ONLY; Gets or sets usageBasedRecommendationServiceLevelObjective for service tier advisor. + UsageBasedRecommendationServiceLevelObjective *string `json:"usageBasedRecommendationServiceLevelObjective,omitempty"` + // UsageBasedRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets usageBasedRecommendationServiceLevelObjectiveId for service tier advisor. + UsageBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"usageBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjective - READ-ONLY; Gets or sets databaseSizeBasedRecommendationServiceLevelObjective for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjective *string `json:"databaseSizeBasedRecommendationServiceLevelObjective,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets databaseSizeBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"databaseSizeBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjective - READ-ONLY; Gets or sets disasterPlanBasedRecommendationServiceLevelObjective for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjective *string `json:"disasterPlanBasedRecommendationServiceLevelObjective,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets disasterPlanBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"disasterPlanBasedRecommendationServiceLevelObjectiveId,omitempty"` + // OverallRecommendationServiceLevelObjective - READ-ONLY; Gets or sets overallRecommendationServiceLevelObjective for service tier advisor. + OverallRecommendationServiceLevelObjective *string `json:"overallRecommendationServiceLevelObjective,omitempty"` + // OverallRecommendationServiceLevelObjectiveID - READ-ONLY; Gets or sets overallRecommendationServiceLevelObjectiveId for service tier advisor. + OverallRecommendationServiceLevelObjectiveID *uuid.UUID `json:"overallRecommendationServiceLevelObjectiveId,omitempty"` + // Confidence - READ-ONLY; Gets or sets confidence for service tier advisor. + Confidence *float64 `json:"confidence,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceTierAdvisorProperties. +func (stap ServiceTierAdvisorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku an ARM Resource SKU. +type Sku struct { + // Name - The name of the SKU, typically, a letter + Number code, e.g. P3. + Name *string `json:"name,omitempty"` + // Tier - The tier or edition of the particular SKU, e.g. Basic, Premium. + Tier *string `json:"tier,omitempty"` + // Size - Size of the particular SKU + Size *string `json:"size,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // Capacity - Capacity of the particular SKU. + Capacity *int32 `json:"capacity,omitempty"` +} + +// SloUsageMetric a Slo Usage Metric. +type SloUsageMetric struct { + // ServiceLevelObjective - READ-ONLY; The serviceLevelObjective for SLO usage metric. 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' + ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` + // ServiceLevelObjectiveID - READ-ONLY; The serviceLevelObjectiveId for SLO usage metric. + ServiceLevelObjectiveID *uuid.UUID `json:"serviceLevelObjectiveId,omitempty"` + // InRangeTimeRatio - READ-ONLY; Gets or sets inRangeTimeRatio for SLO usage metric. + InRangeTimeRatio *float64 `json:"inRangeTimeRatio,omitempty"` +} + +// MarshalJSON is the custom marshaler for SloUsageMetric. +func (sum SloUsageMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// StorageCapability the storage account type capability. +type StorageCapability struct { + // StorageAccountType - READ-ONLY; The storage account type for the database's backups. Possible values include: 'StorageAccountType1GRS', 'StorageAccountType1LRS', 'StorageAccountType1ZRS' + StorageAccountType StorageAccountType1 `json:"storageAccountType,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageCapability. +func (sc StorageCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.Reason != nil { + objectMap["reason"] = sc.Reason + } + return json.Marshal(objectMap) +} + +// SubscriptionUsage usage Metric of a Subscription in a Location. +type SubscriptionUsage struct { + autorest.Response `json:"-"` + // SubscriptionUsageProperties - Resource properties. + *SubscriptionUsageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsage. +func (su SubscriptionUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if su.SubscriptionUsageProperties != nil { + objectMap["properties"] = su.SubscriptionUsageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionUsage struct. +func (su *SubscriptionUsage) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subscriptionUsageProperties SubscriptionUsageProperties + err = json.Unmarshal(*v, &subscriptionUsageProperties) + if err != nil { + return err + } + su.SubscriptionUsageProperties = &subscriptionUsageProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + su.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + su.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + su.Type = &typeVar + } + } + } + + return nil +} + +// SubscriptionUsageListResult a list of subscription usage metrics in a location. +type SubscriptionUsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SubscriptionUsage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsageListResult. +func (sulr SubscriptionUsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SubscriptionUsageListResultIterator provides access to a complete listing of SubscriptionUsage values. +type SubscriptionUsageListResultIterator struct { + i int + page SubscriptionUsageListResultPage +} + +// NextWithContext 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 *SubscriptionUsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SubscriptionUsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubscriptionUsageListResultIterator) 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 SubscriptionUsageListResultIterator) Response() SubscriptionUsageListResult { + 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 SubscriptionUsageListResultIterator) Value() SubscriptionUsage { + if !iter.page.NotDone() { + return SubscriptionUsage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubscriptionUsageListResultIterator type. +func NewSubscriptionUsageListResultIterator(page SubscriptionUsageListResultPage) SubscriptionUsageListResultIterator { + return SubscriptionUsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sulr SubscriptionUsageListResult) IsEmpty() bool { + return sulr.Value == nil || len(*sulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sulr SubscriptionUsageListResult) hasNextLink() bool { + return sulr.NextLink != nil && len(*sulr.NextLink) != 0 +} + +// subscriptionUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sulr SubscriptionUsageListResult) subscriptionUsageListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sulr.NextLink))) +} + +// SubscriptionUsageListResultPage contains a page of SubscriptionUsage values. +type SubscriptionUsageListResultPage struct { + fn func(context.Context, SubscriptionUsageListResult) (SubscriptionUsageListResult, error) + sulr SubscriptionUsageListResult +} + +// NextWithContext 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 *SubscriptionUsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sulr) + if err != nil { + return err + } + page.sulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SubscriptionUsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubscriptionUsageListResultPage) NotDone() bool { + return !page.sulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubscriptionUsageListResultPage) Response() SubscriptionUsageListResult { + return page.sulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubscriptionUsageListResultPage) Values() []SubscriptionUsage { + if page.sulr.IsEmpty() { + return nil + } + return *page.sulr.Value +} + +// Creates a new instance of the SubscriptionUsageListResultPage type. +func NewSubscriptionUsageListResultPage(cur SubscriptionUsageListResult, getNextPage func(context.Context, SubscriptionUsageListResult) (SubscriptionUsageListResult, error)) SubscriptionUsageListResultPage { + return SubscriptionUsageListResultPage{ + fn: getNextPage, + sulr: cur, + } +} + +// SubscriptionUsageProperties properties of a subscription usage. +type SubscriptionUsageProperties struct { + // DisplayName - READ-ONLY; User-readable name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; Current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Boundary value of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit of the metric. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsageProperties. +func (sup SubscriptionUsageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgent an Azure SQL Database sync agent. +type SyncAgent struct { + autorest.Response `json:"-"` + // SyncAgentProperties - Resource properties. + *SyncAgentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgent. +func (sa SyncAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sa.SyncAgentProperties != nil { + objectMap["properties"] = sa.SyncAgentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncAgent struct. +func (sa *SyncAgent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncAgentProperties SyncAgentProperties + err = json.Unmarshal(*v, &syncAgentProperties) + if err != nil { + return err + } + sa.SyncAgentProperties = &syncAgentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sa.Type = &typeVar + } + } + } + + return nil +} + +// SyncAgentKeyProperties properties of an Azure SQL Database sync agent key. +type SyncAgentKeyProperties struct { + autorest.Response `json:"-"` + // SyncAgentKey - READ-ONLY; Key of sync agent. + SyncAgentKey *string `json:"syncAgentKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentKeyProperties. +func (sakp SyncAgentKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentLinkedDatabase an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabase struct { + // SyncAgentLinkedDatabaseProperties - Resource properties. + *SyncAgentLinkedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabase. +func (sald SyncAgentLinkedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sald.SyncAgentLinkedDatabaseProperties != nil { + objectMap["properties"] = sald.SyncAgentLinkedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncAgentLinkedDatabase struct. +func (sald *SyncAgentLinkedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncAgentLinkedDatabaseProperties SyncAgentLinkedDatabaseProperties + err = json.Unmarshal(*v, &syncAgentLinkedDatabaseProperties) + if err != nil { + return err + } + sald.SyncAgentLinkedDatabaseProperties = &syncAgentLinkedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sald.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sald.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sald.Type = &typeVar + } + } + } + + return nil +} + +// SyncAgentLinkedDatabaseListResult a list of sync agent linked databases. +type SyncAgentLinkedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncAgentLinkedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabaseListResult. +func (saldlr SyncAgentLinkedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentLinkedDatabaseListResultIterator provides access to a complete listing of +// SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultIterator struct { + i int + page SyncAgentLinkedDatabaseListResultPage +} + +// NextWithContext 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 *SyncAgentLinkedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentLinkedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncAgentLinkedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncAgentLinkedDatabaseListResultIterator) 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 SyncAgentLinkedDatabaseListResultIterator) Response() SyncAgentLinkedDatabaseListResult { + 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 SyncAgentLinkedDatabaseListResultIterator) Value() SyncAgentLinkedDatabase { + if !iter.page.NotDone() { + return SyncAgentLinkedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncAgentLinkedDatabaseListResultIterator type. +func NewSyncAgentLinkedDatabaseListResultIterator(page SyncAgentLinkedDatabaseListResultPage) SyncAgentLinkedDatabaseListResultIterator { + return SyncAgentLinkedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (saldlr SyncAgentLinkedDatabaseListResult) IsEmpty() bool { + return saldlr.Value == nil || len(*saldlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (saldlr SyncAgentLinkedDatabaseListResult) hasNextLink() bool { + return saldlr.NextLink != nil && len(*saldlr.NextLink) != 0 +} + +// syncAgentLinkedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (saldlr SyncAgentLinkedDatabaseListResult) syncAgentLinkedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !saldlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(saldlr.NextLink))) +} + +// SyncAgentLinkedDatabaseListResultPage contains a page of SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultPage struct { + fn func(context.Context, SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error) + saldlr SyncAgentLinkedDatabaseListResult +} + +// NextWithContext 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 *SyncAgentLinkedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentLinkedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.saldlr) + if err != nil { + return err + } + page.saldlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncAgentLinkedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncAgentLinkedDatabaseListResultPage) NotDone() bool { + return !page.saldlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncAgentLinkedDatabaseListResultPage) Response() SyncAgentLinkedDatabaseListResult { + return page.saldlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncAgentLinkedDatabaseListResultPage) Values() []SyncAgentLinkedDatabase { + if page.saldlr.IsEmpty() { + return nil + } + return *page.saldlr.Value +} + +// Creates a new instance of the SyncAgentLinkedDatabaseListResultPage type. +func NewSyncAgentLinkedDatabaseListResultPage(cur SyncAgentLinkedDatabaseListResult, getNextPage func(context.Context, SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error)) SyncAgentLinkedDatabaseListResultPage { + return SyncAgentLinkedDatabaseListResultPage{ + fn: getNextPage, + saldlr: cur, + } +} + +// SyncAgentLinkedDatabaseProperties properties of an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabaseProperties struct { + // DatabaseType - READ-ONLY; Type of the sync agent linked database. Possible values include: 'AzureSQLDatabase', 'SQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // DatabaseID - READ-ONLY; Id of the sync agent linked database. + DatabaseID *string `json:"databaseId,omitempty"` + // Description - READ-ONLY; Description of the sync agent linked database. + Description *string `json:"description,omitempty"` + // ServerName - READ-ONLY; Server name of the sync agent linked database. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name of the sync agent linked database. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - READ-ONLY; User name of the sync agent linked database. + UserName *string `json:"userName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabaseProperties. +func (saldp SyncAgentLinkedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentListResult a list of sync agents. +type SyncAgentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncAgent `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentListResult. +func (salr SyncAgentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentListResultIterator provides access to a complete listing of SyncAgent values. +type SyncAgentListResultIterator struct { + i int + page SyncAgentListResultPage +} + +// NextWithContext 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 *SyncAgentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncAgentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncAgentListResultIterator) 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 SyncAgentListResultIterator) Response() SyncAgentListResult { + 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 SyncAgentListResultIterator) Value() SyncAgent { + if !iter.page.NotDone() { + return SyncAgent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncAgentListResultIterator type. +func NewSyncAgentListResultIterator(page SyncAgentListResultPage) SyncAgentListResultIterator { + return SyncAgentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (salr SyncAgentListResult) IsEmpty() bool { + return salr.Value == nil || len(*salr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (salr SyncAgentListResult) hasNextLink() bool { + return salr.NextLink != nil && len(*salr.NextLink) != 0 +} + +// syncAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (salr SyncAgentListResult) syncAgentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !salr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(salr.NextLink))) +} + +// SyncAgentListResultPage contains a page of SyncAgent values. +type SyncAgentListResultPage struct { + fn func(context.Context, SyncAgentListResult) (SyncAgentListResult, error) + salr SyncAgentListResult +} + +// NextWithContext 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 *SyncAgentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.salr) + if err != nil { + return err + } + page.salr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncAgentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncAgentListResultPage) NotDone() bool { + return !page.salr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncAgentListResultPage) Response() SyncAgentListResult { + return page.salr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncAgentListResultPage) Values() []SyncAgent { + if page.salr.IsEmpty() { + return nil + } + return *page.salr.Value +} + +// Creates a new instance of the SyncAgentListResultPage type. +func NewSyncAgentListResultPage(cur SyncAgentListResult, getNextPage func(context.Context, SyncAgentListResult) (SyncAgentListResult, error)) SyncAgentListResultPage { + return SyncAgentListResultPage{ + fn: getNextPage, + salr: cur, + } +} + +// SyncAgentProperties properties of an Azure SQL Database sync agent. +type SyncAgentProperties struct { + // Name - READ-ONLY; Name of the sync agent. + Name *string `json:"name,omitempty"` + // SyncDatabaseID - ARM resource id of the sync database in the sync agent. + SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` + // LastAliveTime - READ-ONLY; Last alive time of the sync agent. + LastAliveTime *date.Time `json:"lastAliveTime,omitempty"` + // State - READ-ONLY; State of the sync agent. Possible values include: 'SyncAgentStateOnline', 'SyncAgentStateOffline', 'SyncAgentStateNeverConnected' + State SyncAgentState `json:"state,omitempty"` + // IsUpToDate - READ-ONLY; If the sync agent version is up to date. + IsUpToDate *bool `json:"isUpToDate,omitempty"` + // ExpiryTime - READ-ONLY; Expiration time of the sync agent version. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Version - READ-ONLY; Version of the sync agent. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentProperties. +func (sap SyncAgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sap.SyncDatabaseID != nil { + objectMap["syncDatabaseId"] = sap.SyncDatabaseID + } + return json.Marshal(objectMap) +} + +// SyncAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncAgentsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncAgentsClient) (SyncAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncAgentsCreateOrUpdateFuture.Result. +func (future *SyncAgentsCreateOrUpdateFuture) result(client SyncAgentsClient) (sa SyncAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sa.Response.Response, err = future.GetResult(sender); err == nil && sa.Response.Response.StatusCode != http.StatusNoContent { + sa, err = client.CreateOrUpdateResponder(sa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", sa.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncAgentsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncAgentsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncAgentsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncAgentsDeleteFuture.Result. +func (future *SyncAgentsDeleteFuture) result(client SyncAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncDatabaseIDListResult a list of sync database ID properties. +type SyncDatabaseIDListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncDatabaseIDProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncDatabaseIDListResult. +func (sdilr SyncDatabaseIDListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncDatabaseIDListResultIterator provides access to a complete listing of SyncDatabaseIDProperties +// values. +type SyncDatabaseIDListResultIterator struct { + i int + page SyncDatabaseIDListResultPage +} + +// NextWithContext 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 *SyncDatabaseIDListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncDatabaseIDListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncDatabaseIDListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncDatabaseIDListResultIterator) 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 SyncDatabaseIDListResultIterator) Response() SyncDatabaseIDListResult { + 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 SyncDatabaseIDListResultIterator) Value() SyncDatabaseIDProperties { + if !iter.page.NotDone() { + return SyncDatabaseIDProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncDatabaseIDListResultIterator type. +func NewSyncDatabaseIDListResultIterator(page SyncDatabaseIDListResultPage) SyncDatabaseIDListResultIterator { + return SyncDatabaseIDListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdilr SyncDatabaseIDListResult) IsEmpty() bool { + return sdilr.Value == nil || len(*sdilr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdilr SyncDatabaseIDListResult) hasNextLink() bool { + return sdilr.NextLink != nil && len(*sdilr.NextLink) != 0 +} + +// syncDatabaseIDListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdilr SyncDatabaseIDListResult) syncDatabaseIDListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdilr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdilr.NextLink))) +} + +// SyncDatabaseIDListResultPage contains a page of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultPage struct { + fn func(context.Context, SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error) + sdilr SyncDatabaseIDListResult +} + +// NextWithContext 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 *SyncDatabaseIDListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncDatabaseIDListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdilr) + if err != nil { + return err + } + page.sdilr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncDatabaseIDListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncDatabaseIDListResultPage) NotDone() bool { + return !page.sdilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncDatabaseIDListResultPage) Response() SyncDatabaseIDListResult { + return page.sdilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncDatabaseIDListResultPage) Values() []SyncDatabaseIDProperties { + if page.sdilr.IsEmpty() { + return nil + } + return *page.sdilr.Value +} + +// Creates a new instance of the SyncDatabaseIDListResultPage type. +func NewSyncDatabaseIDListResultPage(cur SyncDatabaseIDListResult, getNextPage func(context.Context, SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error)) SyncDatabaseIDListResultPage { + return SyncDatabaseIDListResultPage{ + fn: getNextPage, + sdilr: cur, + } +} + +// SyncDatabaseIDProperties properties of the sync database id. +type SyncDatabaseIDProperties struct { + // ID - READ-ONLY; ARM resource id of sync database. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncDatabaseIDProperties. +func (sdip SyncDatabaseIDProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaProperties properties of the database full schema. +type SyncFullSchemaProperties struct { + // Tables - READ-ONLY; List of tables in the database full schema. + Tables *[]SyncFullSchemaTable `json:"tables,omitempty"` + // LastUpdateTime - READ-ONLY; Last update time of the database schema. + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaProperties. +func (sfsp SyncFullSchemaProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaPropertiesListResult a list of sync schema properties. +type SyncFullSchemaPropertiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncFullSchemaProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaPropertiesListResult. +func (sfsplr SyncFullSchemaPropertiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaPropertiesListResultIterator provides access to a complete listing of +// SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultIterator struct { + i int + page SyncFullSchemaPropertiesListResultPage +} + +// NextWithContext 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 *SyncFullSchemaPropertiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncFullSchemaPropertiesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncFullSchemaPropertiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncFullSchemaPropertiesListResultIterator) 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 SyncFullSchemaPropertiesListResultIterator) Response() SyncFullSchemaPropertiesListResult { + 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 SyncFullSchemaPropertiesListResultIterator) Value() SyncFullSchemaProperties { + if !iter.page.NotDone() { + return SyncFullSchemaProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncFullSchemaPropertiesListResultIterator type. +func NewSyncFullSchemaPropertiesListResultIterator(page SyncFullSchemaPropertiesListResultPage) SyncFullSchemaPropertiesListResultIterator { + return SyncFullSchemaPropertiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sfsplr SyncFullSchemaPropertiesListResult) IsEmpty() bool { + return sfsplr.Value == nil || len(*sfsplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sfsplr SyncFullSchemaPropertiesListResult) hasNextLink() bool { + return sfsplr.NextLink != nil && len(*sfsplr.NextLink) != 0 +} + +// syncFullSchemaPropertiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sfsplr SyncFullSchemaPropertiesListResult) syncFullSchemaPropertiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sfsplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sfsplr.NextLink))) +} + +// SyncFullSchemaPropertiesListResultPage contains a page of SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultPage struct { + fn func(context.Context, SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error) + sfsplr SyncFullSchemaPropertiesListResult +} + +// NextWithContext 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 *SyncFullSchemaPropertiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncFullSchemaPropertiesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sfsplr) + if err != nil { + return err + } + page.sfsplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncFullSchemaPropertiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncFullSchemaPropertiesListResultPage) NotDone() bool { + return !page.sfsplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncFullSchemaPropertiesListResultPage) Response() SyncFullSchemaPropertiesListResult { + return page.sfsplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncFullSchemaPropertiesListResultPage) Values() []SyncFullSchemaProperties { + if page.sfsplr.IsEmpty() { + return nil + } + return *page.sfsplr.Value +} + +// Creates a new instance of the SyncFullSchemaPropertiesListResultPage type. +func NewSyncFullSchemaPropertiesListResultPage(cur SyncFullSchemaPropertiesListResult, getNextPage func(context.Context, SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error)) SyncFullSchemaPropertiesListResultPage { + return SyncFullSchemaPropertiesListResultPage{ + fn: getNextPage, + sfsplr: cur, + } +} + +// SyncFullSchemaTable properties of the table in the database full schema. +type SyncFullSchemaTable struct { + // Columns - READ-ONLY; List of columns in the table of database full schema. + Columns *[]SyncFullSchemaTableColumn `json:"columns,omitempty"` + // ErrorID - READ-ONLY; Error id of the table. + ErrorID *string `json:"errorId,omitempty"` + // HasError - READ-ONLY; If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // Name - READ-ONLY; Name of the table. + Name *string `json:"name,omitempty"` + // QuotedName - READ-ONLY; Quoted name of the table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaTable. +func (sfst SyncFullSchemaTable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaTableColumn properties of the column in the table of database full schema. +type SyncFullSchemaTableColumn struct { + // DataSize - READ-ONLY; Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - READ-ONLY; Data type of the column. + DataType *string `json:"dataType,omitempty"` + // ErrorID - READ-ONLY; Error id of the column. + ErrorID *string `json:"errorId,omitempty"` + // HasError - READ-ONLY; If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // IsPrimaryKey - READ-ONLY; If it is the primary key of the table. + IsPrimaryKey *bool `json:"isPrimaryKey,omitempty"` + // Name - READ-ONLY; Name of the column. + Name *string `json:"name,omitempty"` + // QuotedName - READ-ONLY; Quoted name of the column. + QuotedName *string `json:"quotedName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaTableColumn. +func (sfstc SyncFullSchemaTableColumn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroup an Azure SQL Database sync group. +type SyncGroup struct { + autorest.Response `json:"-"` + // SyncGroupProperties - Resource properties. + *SyncGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroup. +func (sg SyncGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sg.SyncGroupProperties != nil { + objectMap["properties"] = sg.SyncGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncGroup struct. +func (sg *SyncGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncGroupProperties SyncGroupProperties + err = json.Unmarshal(*v, &syncGroupProperties) + if err != nil { + return err + } + sg.SyncGroupProperties = &syncGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sg.Type = &typeVar + } + } + } + + return nil +} + +// SyncGroupListResult a list of sync groups. +type SyncGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupListResult. +func (sglr SyncGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupListResultIterator provides access to a complete listing of SyncGroup values. +type SyncGroupListResultIterator struct { + i int + page SyncGroupListResultPage +} + +// NextWithContext 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 *SyncGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncGroupListResultIterator) 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 SyncGroupListResultIterator) Response() SyncGroupListResult { + 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 SyncGroupListResultIterator) Value() SyncGroup { + if !iter.page.NotDone() { + return SyncGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncGroupListResultIterator type. +func NewSyncGroupListResultIterator(page SyncGroupListResultPage) SyncGroupListResultIterator { + return SyncGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sglr SyncGroupListResult) IsEmpty() bool { + return sglr.Value == nil || len(*sglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sglr SyncGroupListResult) hasNextLink() bool { + return sglr.NextLink != nil && len(*sglr.NextLink) != 0 +} + +// syncGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sglr SyncGroupListResult) syncGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sglr.NextLink))) +} + +// SyncGroupListResultPage contains a page of SyncGroup values. +type SyncGroupListResultPage struct { + fn func(context.Context, SyncGroupListResult) (SyncGroupListResult, error) + sglr SyncGroupListResult +} + +// NextWithContext 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 *SyncGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sglr) + if err != nil { + return err + } + page.sglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncGroupListResultPage) NotDone() bool { + return !page.sglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncGroupListResultPage) Response() SyncGroupListResult { + return page.sglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncGroupListResultPage) Values() []SyncGroup { + if page.sglr.IsEmpty() { + return nil + } + return *page.sglr.Value +} + +// Creates a new instance of the SyncGroupListResultPage type. +func NewSyncGroupListResultPage(cur SyncGroupListResult, getNextPage func(context.Context, SyncGroupListResult) (SyncGroupListResult, error)) SyncGroupListResultPage { + return SyncGroupListResultPage{ + fn: getNextPage, + sglr: cur, + } +} + +// SyncGroupLogListResult a list of sync group log properties. +type SyncGroupLogListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncGroupLogProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupLogListResult. +func (sgllr SyncGroupLogListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupLogListResultIterator provides access to a complete listing of SyncGroupLogProperties values. +type SyncGroupLogListResultIterator struct { + i int + page SyncGroupLogListResultPage +} + +// NextWithContext 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 *SyncGroupLogListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupLogListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncGroupLogListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncGroupLogListResultIterator) 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 SyncGroupLogListResultIterator) Response() SyncGroupLogListResult { + 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 SyncGroupLogListResultIterator) Value() SyncGroupLogProperties { + if !iter.page.NotDone() { + return SyncGroupLogProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncGroupLogListResultIterator type. +func NewSyncGroupLogListResultIterator(page SyncGroupLogListResultPage) SyncGroupLogListResultIterator { + return SyncGroupLogListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sgllr SyncGroupLogListResult) IsEmpty() bool { + return sgllr.Value == nil || len(*sgllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sgllr SyncGroupLogListResult) hasNextLink() bool { + return sgllr.NextLink != nil && len(*sgllr.NextLink) != 0 +} + +// syncGroupLogListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sgllr SyncGroupLogListResult) syncGroupLogListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sgllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sgllr.NextLink))) +} + +// SyncGroupLogListResultPage contains a page of SyncGroupLogProperties values. +type SyncGroupLogListResultPage struct { + fn func(context.Context, SyncGroupLogListResult) (SyncGroupLogListResult, error) + sgllr SyncGroupLogListResult +} + +// NextWithContext 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 *SyncGroupLogListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupLogListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sgllr) + if err != nil { + return err + } + page.sgllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncGroupLogListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncGroupLogListResultPage) NotDone() bool { + return !page.sgllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncGroupLogListResultPage) Response() SyncGroupLogListResult { + return page.sgllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncGroupLogListResultPage) Values() []SyncGroupLogProperties { + if page.sgllr.IsEmpty() { + return nil + } + return *page.sgllr.Value +} + +// Creates a new instance of the SyncGroupLogListResultPage type. +func NewSyncGroupLogListResultPage(cur SyncGroupLogListResult, getNextPage func(context.Context, SyncGroupLogListResult) (SyncGroupLogListResult, error)) SyncGroupLogListResultPage { + return SyncGroupLogListResultPage{ + fn: getNextPage, + sgllr: cur, + } +} + +// SyncGroupLogProperties properties of an Azure SQL Database sync group log. +type SyncGroupLogProperties struct { + // Timestamp - READ-ONLY; Timestamp of the sync group log. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Type - READ-ONLY; Type of the sync group log. Possible values include: 'SyncGroupLogTypeAll', 'SyncGroupLogTypeError', 'SyncGroupLogTypeWarning', 'SyncGroupLogTypeSuccess' + Type SyncGroupLogType `json:"type,omitempty"` + // Source - READ-ONLY; Source of the sync group log. + Source *string `json:"source,omitempty"` + // Details - READ-ONLY; Details of the sync group log. + Details *string `json:"details,omitempty"` + // TracingID - READ-ONLY; TracingId of the sync group log. + TracingID *uuid.UUID `json:"tracingId,omitempty"` + // OperationStatus - READ-ONLY; OperationStatus of the sync group log. + OperationStatus *string `json:"operationStatus,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupLogProperties. +func (sglp SyncGroupLogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupProperties properties of a sync group. +type SyncGroupProperties struct { + // Interval - Sync interval of the sync group. + Interval *int32 `json:"interval,omitempty"` + // LastSyncTime - READ-ONLY; Last sync time of the sync group. + LastSyncTime *date.Time `json:"lastSyncTime,omitempty"` + // ConflictResolutionPolicy - Conflict resolution policy of the sync group. Possible values include: 'HubWin', 'MemberWin' + ConflictResolutionPolicy SyncConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // SyncDatabaseID - ARM resource id of the sync database in the sync group. + SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` + // HubDatabaseUserName - User name for the sync group hub database credential. + HubDatabaseUserName *string `json:"hubDatabaseUserName,omitempty"` + // HubDatabasePassword - Password for the sync group hub database credential. + HubDatabasePassword *string `json:"hubDatabasePassword,omitempty"` + // SyncState - READ-ONLY; 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"` + // UsePrivateLinkConnection - If use private link connection is enabled. + UsePrivateLinkConnection *bool `json:"usePrivateLinkConnection,omitempty"` + // PrivateEndpointName - READ-ONLY; Private endpoint name of the sync group if use private link connection is enabled. + PrivateEndpointName *string `json:"privateEndpointName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupProperties. +func (sgp SyncGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sgp.Interval != nil { + objectMap["interval"] = sgp.Interval + } + if sgp.ConflictResolutionPolicy != "" { + objectMap["conflictResolutionPolicy"] = sgp.ConflictResolutionPolicy + } + if sgp.SyncDatabaseID != nil { + objectMap["syncDatabaseId"] = sgp.SyncDatabaseID + } + if sgp.HubDatabaseUserName != nil { + objectMap["hubDatabaseUserName"] = sgp.HubDatabaseUserName + } + if sgp.HubDatabasePassword != nil { + objectMap["hubDatabasePassword"] = sgp.HubDatabasePassword + } + if sgp.Schema != nil { + objectMap["schema"] = sgp.Schema + } + if sgp.UsePrivateLinkConnection != nil { + objectMap["usePrivateLinkConnection"] = sgp.UsePrivateLinkConnection + } + return json.Marshal(objectMap) +} + +// SyncGroupSchema properties of sync group schema. +type SyncGroupSchema struct { + // Tables - List of tables in sync group schema. + Tables *[]SyncGroupSchemaTable `json:"tables,omitempty"` + // MasterSyncMemberName - Name of master sync member where the schema is from. + MasterSyncMemberName *string `json:"masterSyncMemberName,omitempty"` +} + +// SyncGroupSchemaTable properties of table in sync group schema. +type SyncGroupSchemaTable struct { + // Columns - List of columns in sync group schema. + Columns *[]SyncGroupSchemaTableColumn `json:"columns,omitempty"` + // QuotedName - Quoted name of sync group schema table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncGroupSchemaTableColumn properties of column in sync group table. +type SyncGroupSchemaTableColumn struct { + // QuotedName - Quoted name of sync group table column. + QuotedName *string `json:"quotedName,omitempty"` + // DataSize - Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - Data type of the column. + DataType *string `json:"dataType,omitempty"` +} + +// SyncGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (SyncGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsCreateOrUpdateFuture.Result. +func (future *SyncGroupsCreateOrUpdateFuture) result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent { + sg, err = client.CreateOrUpdateResponder(sg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", sg.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsDeleteFuture.Result. +func (future *SyncGroupsDeleteFuture) result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncGroupsRefreshHubSchemaFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncGroupsRefreshHubSchemaFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsRefreshHubSchemaFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsRefreshHubSchemaFuture.Result. +func (future *SyncGroupsRefreshHubSchemaFuture) result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (SyncGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsUpdateFuture.Result. +func (future *SyncGroupsUpdateFuture) result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent { + sg, err = client.UpdateResponder(sg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", sg.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncMember an Azure SQL Database sync member. +type SyncMember struct { + autorest.Response `json:"-"` + // SyncMemberProperties - Resource properties. + *SyncMemberProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMember. +func (sm SyncMember) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sm.SyncMemberProperties != nil { + objectMap["properties"] = sm.SyncMemberProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncMember struct. +func (sm *SyncMember) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncMemberProperties SyncMemberProperties + err = json.Unmarshal(*v, &syncMemberProperties) + if err != nil { + return err + } + sm.SyncMemberProperties = &syncMemberProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sm.Type = &typeVar + } + } + } + + return nil +} + +// SyncMemberListResult a list of Azure SQL Database sync members. +type SyncMemberListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncMember `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMemberListResult. +func (smlr SyncMemberListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncMemberListResultIterator provides access to a complete listing of SyncMember values. +type SyncMemberListResultIterator struct { + i int + page SyncMemberListResultPage +} + +// NextWithContext 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 *SyncMemberListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMemberListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncMemberListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncMemberListResultIterator) 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 SyncMemberListResultIterator) Response() SyncMemberListResult { + 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 SyncMemberListResultIterator) Value() SyncMember { + if !iter.page.NotDone() { + return SyncMember{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncMemberListResultIterator type. +func NewSyncMemberListResultIterator(page SyncMemberListResultPage) SyncMemberListResultIterator { + return SyncMemberListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (smlr SyncMemberListResult) IsEmpty() bool { + return smlr.Value == nil || len(*smlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (smlr SyncMemberListResult) hasNextLink() bool { + return smlr.NextLink != nil && len(*smlr.NextLink) != 0 +} + +// syncMemberListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smlr SyncMemberListResult) syncMemberListResultPreparer(ctx context.Context) (*http.Request, error) { + if !smlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smlr.NextLink))) +} + +// SyncMemberListResultPage contains a page of SyncMember values. +type SyncMemberListResultPage struct { + fn func(context.Context, SyncMemberListResult) (SyncMemberListResult, error) + smlr SyncMemberListResult +} + +// NextWithContext 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 *SyncMemberListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMemberListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.smlr) + if err != nil { + return err + } + page.smlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SyncMemberListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncMemberListResultPage) NotDone() bool { + return !page.smlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncMemberListResultPage) Response() SyncMemberListResult { + return page.smlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncMemberListResultPage) Values() []SyncMember { + if page.smlr.IsEmpty() { + return nil + } + return *page.smlr.Value +} + +// Creates a new instance of the SyncMemberListResultPage type. +func NewSyncMemberListResultPage(cur SyncMemberListResult, getNextPage func(context.Context, SyncMemberListResult) (SyncMemberListResult, error)) SyncMemberListResultPage { + return SyncMemberListResultPage{ + fn: getNextPage, + smlr: cur, + } +} + +// SyncMemberProperties properties of a sync member. +type SyncMemberProperties struct { + // DatabaseType - Database type of the sync member. Possible values include: 'AzureSQLDatabase', 'SQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // SyncAgentID - ARM resource id of the sync agent in the sync member. + SyncAgentID *string `json:"syncAgentId,omitempty"` + // SQLServerDatabaseID - SQL Server database id of the sync member. + SQLServerDatabaseID *uuid.UUID `json:"sqlServerDatabaseId,omitempty"` + // SyncMemberAzureDatabaseResourceID - ARM resource id of the sync member logical database, for sync members in Azure. + SyncMemberAzureDatabaseResourceID *string `json:"syncMemberAzureDatabaseResourceId,omitempty"` + // UsePrivateLinkConnection - Whether to use private link connection. + UsePrivateLinkConnection *bool `json:"usePrivateLinkConnection,omitempty"` + // PrivateEndpointName - READ-ONLY; Private endpoint name of the sync member if use private link connection is enabled, for sync members in Azure. + PrivateEndpointName *string `json:"privateEndpointName,omitempty"` + // ServerName - Server name of the member database in the sync member + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - Database name of the member database in the sync member. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - User name of the member database in the sync member. + UserName *string `json:"userName,omitempty"` + // Password - Password of the member database in the sync member. + Password *string `json:"password,omitempty"` + // SyncDirection - Sync direction of the sync member. Possible values include: 'Bidirectional', 'OneWayMemberToHub', 'OneWayHubToMember' + SyncDirection SyncDirection `json:"syncDirection,omitempty"` + // SyncState - READ-ONLY; Sync state of the sync member. Possible values include: 'SyncInProgress', 'SyncSucceeded', 'SyncFailed', 'DisabledTombstoneCleanup', 'DisabledBackupRestore', 'SyncSucceededWithWarnings', 'SyncCancelling', 'SyncCancelled', 'UnProvisioned', 'Provisioning', 'Provisioned', 'ProvisionFailed', 'DeProvisioning', 'DeProvisioned', 'DeProvisionFailed', 'Reprovisioning', 'ReprovisionFailed', 'UnReprovisioned' + SyncState SyncMemberState `json:"syncState,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMemberProperties. +func (smp SyncMemberProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smp.DatabaseType != "" { + objectMap["databaseType"] = smp.DatabaseType + } + if smp.SyncAgentID != nil { + objectMap["syncAgentId"] = smp.SyncAgentID + } + if smp.SQLServerDatabaseID != nil { + objectMap["sqlServerDatabaseId"] = smp.SQLServerDatabaseID + } + if smp.SyncMemberAzureDatabaseResourceID != nil { + objectMap["syncMemberAzureDatabaseResourceId"] = smp.SyncMemberAzureDatabaseResourceID + } + if smp.UsePrivateLinkConnection != nil { + objectMap["usePrivateLinkConnection"] = smp.UsePrivateLinkConnection + } + if smp.ServerName != nil { + objectMap["serverName"] = smp.ServerName + } + if smp.DatabaseName != nil { + objectMap["databaseName"] = smp.DatabaseName + } + if smp.UserName != nil { + objectMap["userName"] = smp.UserName + } + if smp.Password != nil { + objectMap["password"] = smp.Password + } + if smp.SyncDirection != "" { + objectMap["syncDirection"] = smp.SyncDirection + } + return json.Marshal(objectMap) +} + +// SyncMembersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncMembersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (SyncMember, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersCreateOrUpdateFuture.Result. +func (future *SyncMembersCreateOrUpdateFuture) result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.CreateOrUpdateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncMembersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersDeleteFuture.Result. +func (future *SyncMembersDeleteFuture) result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncMembersRefreshMemberSchemaFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncMembersRefreshMemberSchemaFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersRefreshMemberSchemaFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersRefreshMemberSchemaFuture.Result. +func (future *SyncMembersRefreshMemberSchemaFuture) result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncMembersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (SyncMember, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersUpdateFuture.Result. +func (future *SyncMembersUpdateFuture) result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.UpdateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// TdeCertificate a TDE certificate that can be uploaded into a server. +type TdeCertificate struct { + // TdeCertificateProperties - Resource properties. + *TdeCertificateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TdeCertificate. +func (tc TdeCertificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tc.TdeCertificateProperties != nil { + objectMap["properties"] = tc.TdeCertificateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TdeCertificate struct. +func (tc *TdeCertificate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tdeCertificateProperties TdeCertificateProperties + err = json.Unmarshal(*v, &tdeCertificateProperties) + if err != nil { + return err + } + tc.TdeCertificateProperties = &tdeCertificateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tc.Type = &typeVar + } + } + } + + return nil +} + +// TdeCertificateProperties properties of a TDE certificate. +type TdeCertificateProperties struct { + // PrivateBlob - The base64 encoded certificate private blob. + PrivateBlob *string `json:"privateBlob,omitempty"` + // CertPassword - The certificate password. + CertPassword *string `json:"certPassword,omitempty"` +} + +// TdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type TdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TdeCertificatesCreateFuture.Result. +func (future *TdeCertificatesCreateFuture) result(client TdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.TdeCertificatesCreateFuture") + return + } + ar.Response = future.Response() + return +} + +// TopQueries ... +type TopQueries struct { + // NumberOfQueries - READ-ONLY; Requested number of top queries. + NumberOfQueries *int32 `json:"numberOfQueries,omitempty"` + // AggregationFunction - READ-ONLY; Aggregation function used to calculate query metrics. + AggregationFunction *string `json:"aggregationFunction,omitempty"` + // ObservationMetric - READ-ONLY; Metric used to rank queries. + ObservationMetric *string `json:"observationMetric,omitempty"` + // IntervalType - READ-ONLY; Interval type (length). Possible values include: 'PT1H', 'P1D' + IntervalType QueryTimeGrainType `json:"intervalType,omitempty"` + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *string `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *string `json:"endTime,omitempty"` + // Queries - List of top resource consuming queries with appropriate metric data + Queries *[]QueryStatisticsProperties `json:"queries,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopQueries. +func (tq TopQueries) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tq.Queries != nil { + objectMap["queries"] = tq.Queries + } + return json.Marshal(objectMap) +} + +// TopQueriesListResult a list of top resource consuming queries on managed instance +type TopQueriesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]TopQueries `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopQueriesListResult. +func (tqlr TopQueriesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TopQueriesListResultIterator provides access to a complete listing of TopQueries values. +type TopQueriesListResultIterator struct { + i int + page TopQueriesListResultPage +} + +// NextWithContext 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 *TopQueriesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueriesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TopQueriesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TopQueriesListResultIterator) 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 TopQueriesListResultIterator) Response() TopQueriesListResult { + 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 TopQueriesListResultIterator) Value() TopQueries { + if !iter.page.NotDone() { + return TopQueries{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TopQueriesListResultIterator type. +func NewTopQueriesListResultIterator(page TopQueriesListResultPage) TopQueriesListResultIterator { + return TopQueriesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tqlr TopQueriesListResult) IsEmpty() bool { + return tqlr.Value == nil || len(*tqlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tqlr TopQueriesListResult) hasNextLink() bool { + return tqlr.NextLink != nil && len(*tqlr.NextLink) != 0 +} + +// topQueriesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tqlr TopQueriesListResult) topQueriesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !tqlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tqlr.NextLink))) +} + +// TopQueriesListResultPage contains a page of TopQueries values. +type TopQueriesListResultPage struct { + fn func(context.Context, TopQueriesListResult) (TopQueriesListResult, error) + tqlr TopQueriesListResult +} + +// NextWithContext 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 *TopQueriesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueriesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tqlr) + if err != nil { + return err + } + page.tqlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *TopQueriesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TopQueriesListResultPage) NotDone() bool { + return !page.tqlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TopQueriesListResultPage) Response() TopQueriesListResult { + return page.tqlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TopQueriesListResultPage) Values() []TopQueries { + if page.tqlr.IsEmpty() { + return nil + } + return *page.tqlr.Value +} + +// Creates a new instance of the TopQueriesListResultPage type. +func NewTopQueriesListResultPage(cur TopQueriesListResult, getNextPage func(context.Context, TopQueriesListResult) (TopQueriesListResult, error)) TopQueriesListResultPage { + return TopQueriesListResultPage{ + fn: getNextPage, + tqlr: cur, + } +} + +// TrackedResource ARM tracked top level resource. +type TrackedResource struct { + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// TransparentDataEncryption represents a database transparent data encryption configuration. +type TransparentDataEncryption struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionProperties - Represents the properties of the resource. + *TransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryption. +func (tde TransparentDataEncryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tde.TransparentDataEncryptionProperties != nil { + objectMap["properties"] = tde.TransparentDataEncryptionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryption struct. +func (tde *TransparentDataEncryption) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tde.Location = &location + } + case "properties": + if v != nil { + var transparentDataEncryptionProperties TransparentDataEncryptionProperties + err = json.Unmarshal(*v, &transparentDataEncryptionProperties) + if err != nil { + return err + } + tde.TransparentDataEncryptionProperties = &transparentDataEncryptionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tde.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tde.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tde.Type = &typeVar + } + } + } + + return nil +} + +// TransparentDataEncryptionActivity represents a database transparent data encryption Scan. +type TransparentDataEncryptionActivity struct { + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionActivityProperties - Represents the properties of the resource. + *TransparentDataEncryptionActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivity. +func (tdea TransparentDataEncryptionActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tdea.TransparentDataEncryptionActivityProperties != nil { + objectMap["properties"] = tdea.TransparentDataEncryptionActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryptionActivity struct. +func (tdea *TransparentDataEncryptionActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tdea.Location = &location + } + case "properties": + if v != nil { + var transparentDataEncryptionActivityProperties TransparentDataEncryptionActivityProperties + err = json.Unmarshal(*v, &transparentDataEncryptionActivityProperties) + if err != nil { + return err + } + tdea.TransparentDataEncryptionActivityProperties = &transparentDataEncryptionActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tdea.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tdea.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tdea.Type = &typeVar + } + } + } + + return nil +} + +// TransparentDataEncryptionActivityListResult represents the response to a list database transparent data +// encryption activity request. +type TransparentDataEncryptionActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of database transparent data encryption activities. + Value *[]TransparentDataEncryptionActivity `json:"value,omitempty"` +} + +// TransparentDataEncryptionActivityProperties represents the properties of a database transparent data +// encryption Scan. +type TransparentDataEncryptionActivityProperties struct { + // Status - READ-ONLY; The status of the database. Possible values include: 'Encrypting', 'Decrypting' + Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` + // PercentComplete - READ-ONLY; The percent complete of the transparent data encryption scan for a database. + PercentComplete *float64 `json:"percentComplete,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivityProperties. +func (tdeap TransparentDataEncryptionActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TransparentDataEncryptionProperties represents the properties of a database transparent data encryption. +type TransparentDataEncryptionProperties struct { + // Status - The status of the database transparent data encryption. Possible values include: 'TransparentDataEncryptionStatusEnabled', 'TransparentDataEncryptionStatusDisabled' + Status TransparentDataEncryptionStatus `json:"status,omitempty"` +} + +// UnlinkParameters represents the parameters for Unlink Replication Link request. +type UnlinkParameters struct { + // ForcedTermination - Determines whether link will be terminated in a forced or a friendly way. + ForcedTermination *bool `json:"forcedTermination,omitempty"` +} + +// UpsertManagedServerOperationParameters ... +type UpsertManagedServerOperationParameters struct { + Family *string `json:"family,omitempty"` + Tier *string `json:"tier,omitempty"` + VCores *int32 `json:"vCores,omitempty"` + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` +} + +// UpsertManagedServerOperationStep ... +type UpsertManagedServerOperationStep struct { + Order *int32 `json:"order,omitempty"` + Name *string `json:"name,omitempty"` + // Status - Possible values include: 'StatusNotStarted', 'StatusInProgress', 'StatusSlowedDown', 'StatusCompleted', 'StatusFailed', 'StatusCanceled' + Status Status `json:"status,omitempty"` +} + +// Usage ARM usage. +type Usage struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *Name `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // Unit - READ-ONLY; Usage unit. + Unit *string `json:"unit,omitempty"` + // CurrentValue - READ-ONLY; Usage current value. + CurrentValue *int32 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Usage limit. + Limit *int32 `json:"limit,omitempty"` + // RequestedLimit - READ-ONLY; Usage requested limit. + RequestedLimit *int32 `json:"requestedLimit,omitempty"` +} + +// MarshalJSON is the custom marshaler for Usage. +func (u Usage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UsageListResult a list of usages. +type UsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Usage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for UsageListResult. +func (ulr UsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UsageListResultIterator provides access to a complete listing of Usage values. +type UsageListResultIterator struct { + i int + page UsageListResultPage +} + +// NextWithContext 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 *UsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *UsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UsageListResultIterator) 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 UsageListResultIterator) Response() UsageListResult { + 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 UsageListResultIterator) Value() Usage { + if !iter.page.NotDone() { + return Usage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UsageListResultIterator type. +func NewUsageListResultIterator(page UsageListResultPage) UsageListResultIterator { + return UsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ulr UsageListResult) IsEmpty() bool { + return ulr.Value == nil || len(*ulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ulr UsageListResult) hasNextLink() bool { + return ulr.NextLink != nil && len(*ulr.NextLink) != 0 +} + +// usageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ulr UsageListResult) usageListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ulr.NextLink))) +} + +// UsageListResultPage contains a page of Usage values. +type UsageListResultPage struct { + fn func(context.Context, UsageListResult) (UsageListResult, error) + ulr UsageListResult +} + +// NextWithContext 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 *UsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ulr) + if err != nil { + return err + } + page.ulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *UsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UsageListResultPage) NotDone() bool { + return !page.ulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UsageListResultPage) Response() UsageListResult { + return page.ulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UsageListResultPage) Values() []Usage { + if page.ulr.IsEmpty() { + return nil + } + return *page.ulr.Value +} + +// Creates a new instance of the UsageListResultPage type. +func NewUsageListResultPage(cur UsageListResult, getNextPage func(context.Context, UsageListResult) (UsageListResult, error)) UsageListResultPage { + return UsageListResultPage{ + fn: getNextPage, + ulr: cur, + } +} + +// VirtualCluster an Azure SQL virtual cluster. +type VirtualCluster struct { + autorest.Response `json:"-"` + // VirtualClusterProperties - Resource properties. + *VirtualClusterProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualCluster. +func (vc VirtualCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vc.VirtualClusterProperties != nil { + objectMap["properties"] = vc.VirtualClusterProperties + } + if vc.Location != nil { + objectMap["location"] = vc.Location + } + if vc.Tags != nil { + objectMap["tags"] = vc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualCluster struct. +func (vc *VirtualCluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualClusterProperties VirtualClusterProperties + err = json.Unmarshal(*v, &virtualClusterProperties) + if err != nil { + return err + } + vc.VirtualClusterProperties = &virtualClusterProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vc.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vc.Type = &typeVar + } + } + } + + return nil +} + +// VirtualClusterListResult a list of virtual clusters. +type VirtualClusterListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VirtualCluster `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterListResult. +func (vclr VirtualClusterListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualClusterListResultIterator provides access to a complete listing of VirtualCluster values. +type VirtualClusterListResultIterator struct { + i int + page VirtualClusterListResultPage +} + +// NextWithContext 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 *VirtualClusterListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClusterListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VirtualClusterListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VirtualClusterListResultIterator) 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 VirtualClusterListResultIterator) Response() VirtualClusterListResult { + 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 VirtualClusterListResultIterator) Value() VirtualCluster { + if !iter.page.NotDone() { + return VirtualCluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VirtualClusterListResultIterator type. +func NewVirtualClusterListResultIterator(page VirtualClusterListResultPage) VirtualClusterListResultIterator { + return VirtualClusterListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vclr VirtualClusterListResult) IsEmpty() bool { + return vclr.Value == nil || len(*vclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vclr VirtualClusterListResult) hasNextLink() bool { + return vclr.NextLink != nil && len(*vclr.NextLink) != 0 +} + +// virtualClusterListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vclr VirtualClusterListResult) virtualClusterListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vclr.NextLink))) +} + +// VirtualClusterListResultPage contains a page of VirtualCluster values. +type VirtualClusterListResultPage struct { + fn func(context.Context, VirtualClusterListResult) (VirtualClusterListResult, error) + vclr VirtualClusterListResult +} + +// NextWithContext 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 *VirtualClusterListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClusterListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vclr) + if err != nil { + return err + } + page.vclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VirtualClusterListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VirtualClusterListResultPage) NotDone() bool { + return !page.vclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VirtualClusterListResultPage) Response() VirtualClusterListResult { + return page.vclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VirtualClusterListResultPage) Values() []VirtualCluster { + if page.vclr.IsEmpty() { + return nil + } + return *page.vclr.Value +} + +// Creates a new instance of the VirtualClusterListResultPage type. +func NewVirtualClusterListResultPage(cur VirtualClusterListResult, getNextPage func(context.Context, VirtualClusterListResult) (VirtualClusterListResult, error)) VirtualClusterListResultPage { + return VirtualClusterListResultPage{ + fn: getNextPage, + vclr: cur, + } +} + +// VirtualClusterProperties the properties of a virtual cluster. +type VirtualClusterProperties struct { + // SubnetID - READ-ONLY; Subnet resource ID for the virtual cluster. + SubnetID *string `json:"subnetId,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // ChildResources - READ-ONLY; List of resources in this virtual cluster. + ChildResources *[]string `json:"childResources,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterProperties. +func (vcp VirtualClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcp.Family != nil { + objectMap["family"] = vcp.Family + } + return json.Marshal(objectMap) +} + +// VirtualClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualClustersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualClustersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualClustersDeleteFuture.Result. +func (future *VirtualClustersDeleteFuture) result(client VirtualClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// VirtualClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualClustersClient) (VirtualCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualClustersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualClustersUpdateFuture.Result. +func (future *VirtualClustersUpdateFuture) result(client VirtualClustersClient) (vc VirtualCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + vc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vc.Response.Response, err = future.GetResult(sender); err == nil && vc.Response.Response.StatusCode != http.StatusNoContent { + vc, err = client.UpdateResponder(vc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersUpdateFuture", "Result", vc.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualClusterUpdate an update request for an Azure SQL Database virtual cluster. +type VirtualClusterUpdate struct { + // VirtualClusterProperties - Resource properties. + *VirtualClusterProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterUpdate. +func (vcu VirtualClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcu.VirtualClusterProperties != nil { + objectMap["properties"] = vcu.VirtualClusterProperties + } + if vcu.Tags != nil { + objectMap["tags"] = vcu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualClusterUpdate struct. +func (vcu *VirtualClusterUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualClusterProperties VirtualClusterProperties + err = json.Unmarshal(*v, &virtualClusterProperties) + if err != nil { + return err + } + vcu.VirtualClusterProperties = &virtualClusterProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vcu.Tags = tags + } + } + } + + return nil +} + +// VirtualNetworkRule a virtual network rule. +type VirtualNetworkRule struct { + autorest.Response `json:"-"` + // VirtualNetworkRuleProperties - Resource properties. + *VirtualNetworkRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRule. +func (vnr VirtualNetworkRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnr.VirtualNetworkRuleProperties != nil { + objectMap["properties"] = vnr.VirtualNetworkRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualNetworkRule struct. +func (vnr *VirtualNetworkRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualNetworkRuleProperties VirtualNetworkRuleProperties + err = json.Unmarshal(*v, &virtualNetworkRuleProperties) + if err != nil { + return err + } + vnr.VirtualNetworkRuleProperties = &virtualNetworkRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vnr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vnr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vnr.Type = &typeVar + } + } + } + + return nil +} + +// VirtualNetworkRuleListResult a list of virtual network rules. +type VirtualNetworkRuleListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VirtualNetworkRule `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRuleListResult. +func (vnrlr VirtualNetworkRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkRuleListResultIterator provides access to a complete listing of VirtualNetworkRule values. +type VirtualNetworkRuleListResultIterator struct { + i int + page VirtualNetworkRuleListResultPage +} + +// NextWithContext 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 *VirtualNetworkRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VirtualNetworkRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VirtualNetworkRuleListResultIterator) 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 VirtualNetworkRuleListResultIterator) Response() VirtualNetworkRuleListResult { + 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 VirtualNetworkRuleListResultIterator) Value() VirtualNetworkRule { + if !iter.page.NotDone() { + return VirtualNetworkRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VirtualNetworkRuleListResultIterator type. +func NewVirtualNetworkRuleListResultIterator(page VirtualNetworkRuleListResultPage) VirtualNetworkRuleListResultIterator { + return VirtualNetworkRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vnrlr VirtualNetworkRuleListResult) IsEmpty() bool { + return vnrlr.Value == nil || len(*vnrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vnrlr VirtualNetworkRuleListResult) hasNextLink() bool { + return vnrlr.NextLink != nil && len(*vnrlr.NextLink) != 0 +} + +// virtualNetworkRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vnrlr VirtualNetworkRuleListResult) virtualNetworkRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vnrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vnrlr.NextLink))) +} + +// VirtualNetworkRuleListResultPage contains a page of VirtualNetworkRule values. +type VirtualNetworkRuleListResultPage struct { + fn func(context.Context, VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error) + vnrlr VirtualNetworkRuleListResult +} + +// NextWithContext 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 *VirtualNetworkRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vnrlr) + if err != nil { + return err + } + page.vnrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VirtualNetworkRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VirtualNetworkRuleListResultPage) NotDone() bool { + return !page.vnrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VirtualNetworkRuleListResultPage) Response() VirtualNetworkRuleListResult { + return page.vnrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VirtualNetworkRuleListResultPage) Values() []VirtualNetworkRule { + if page.vnrlr.IsEmpty() { + return nil + } + return *page.vnrlr.Value +} + +// Creates a new instance of the VirtualNetworkRuleListResultPage type. +func NewVirtualNetworkRuleListResultPage(cur VirtualNetworkRuleListResult, getNextPage func(context.Context, VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error)) VirtualNetworkRuleListResultPage { + return VirtualNetworkRuleListResultPage{ + fn: getNextPage, + vnrlr: cur, + } +} + +// VirtualNetworkRuleProperties properties of a virtual network rule. +type VirtualNetworkRuleProperties struct { + // VirtualNetworkSubnetID - The ARM resource id of the virtual network subnet. + VirtualNetworkSubnetID *string `json:"virtualNetworkSubnetId,omitempty"` + // IgnoreMissingVnetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled. + IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` + // State - READ-ONLY; Virtual Network Rule State. Possible values include: 'VirtualNetworkRuleStateInitializing', 'VirtualNetworkRuleStateInProgress', 'VirtualNetworkRuleStateReady', 'VirtualNetworkRuleStateDeleting', 'VirtualNetworkRuleStateUnknown' + State VirtualNetworkRuleState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRuleProperties. +func (vnrp VirtualNetworkRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnrp.VirtualNetworkSubnetID != nil { + objectMap["virtualNetworkSubnetId"] = vnrp.VirtualNetworkSubnetID + } + if vnrp.IgnoreMissingVnetServiceEndpoint != nil { + objectMap["ignoreMissingVnetServiceEndpoint"] = vnrp.IgnoreMissingVnetServiceEndpoint + } + return json.Marshal(objectMap) +} + +// VirtualNetworkRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualNetworkRulesClient) (VirtualNetworkRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualNetworkRulesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualNetworkRulesCreateOrUpdateFuture.Result. +func (future *VirtualNetworkRulesCreateOrUpdateFuture) result(client VirtualNetworkRulesClient) (vnr VirtualNetworkRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + vnr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vnr.Response.Response, err = future.GetResult(sender); err == nil && vnr.Response.Response.StatusCode != http.StatusNoContent { + vnr, err = client.CreateOrUpdateResponder(vnr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", vnr.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualNetworkRulesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualNetworkRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualNetworkRulesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualNetworkRulesDeleteFuture.Result. +func (future *VirtualNetworkRulesDeleteFuture) result(client VirtualNetworkRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// VulnerabilityAssessmentRecurringScansProperties properties of a Vulnerability Assessment recurring +// scans. +type VulnerabilityAssessmentRecurringScansProperties struct { + // IsEnabled - Recurring scans state. + IsEnabled *bool `json:"isEnabled,omitempty"` + // EmailSubscriptionAdmins - Specifies that the schedule scan notification will be is sent to the subscription administrators. + EmailSubscriptionAdmins *bool `json:"emailSubscriptionAdmins,omitempty"` + // Emails - Specifies an array of e-mail addresses to which the scan notification is sent. + Emails *[]string `json:"emails,omitempty"` +} + +// VulnerabilityAssessmentScanError properties of a vulnerability assessment scan error. +type VulnerabilityAssessmentScanError struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanError. +func (vase VulnerabilityAssessmentScanError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentScanRecord a vulnerability assessment scan record. +type VulnerabilityAssessmentScanRecord struct { + autorest.Response `json:"-"` + // VulnerabilityAssessmentScanRecordProperties - Resource properties. + *VulnerabilityAssessmentScanRecordProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecord. +func (vasr VulnerabilityAssessmentScanRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vasr.VulnerabilityAssessmentScanRecordProperties != nil { + objectMap["properties"] = vasr.VulnerabilityAssessmentScanRecordProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VulnerabilityAssessmentScanRecord struct. +func (vasr *VulnerabilityAssessmentScanRecord) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var vulnerabilityAssessmentScanRecordProperties VulnerabilityAssessmentScanRecordProperties + err = json.Unmarshal(*v, &vulnerabilityAssessmentScanRecordProperties) + if err != nil { + return err + } + vasr.VulnerabilityAssessmentScanRecordProperties = &vulnerabilityAssessmentScanRecordProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vasr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vasr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vasr.Type = &typeVar + } + } + } + + return nil +} + +// VulnerabilityAssessmentScanRecordListResult a list of vulnerability assessment scan records. +type VulnerabilityAssessmentScanRecordListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VulnerabilityAssessmentScanRecord `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecordListResult. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentScanRecordListResultIterator provides access to a complete listing of +// VulnerabilityAssessmentScanRecord values. +type VulnerabilityAssessmentScanRecordListResultIterator struct { + i int + page VulnerabilityAssessmentScanRecordListResultPage +} + +// NextWithContext 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 *VulnerabilityAssessmentScanRecordListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VulnerabilityAssessmentScanRecordListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VulnerabilityAssessmentScanRecordListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VulnerabilityAssessmentScanRecordListResultIterator) 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 VulnerabilityAssessmentScanRecordListResultIterator) Response() VulnerabilityAssessmentScanRecordListResult { + 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 VulnerabilityAssessmentScanRecordListResultIterator) Value() VulnerabilityAssessmentScanRecord { + if !iter.page.NotDone() { + return VulnerabilityAssessmentScanRecord{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VulnerabilityAssessmentScanRecordListResultIterator type. +func NewVulnerabilityAssessmentScanRecordListResultIterator(page VulnerabilityAssessmentScanRecordListResultPage) VulnerabilityAssessmentScanRecordListResultIterator { + return VulnerabilityAssessmentScanRecordListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) IsEmpty() bool { + return vasrlr.Value == nil || len(*vasrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) hasNextLink() bool { + return vasrlr.NextLink != nil && len(*vasrlr.NextLink) != 0 +} + +// vulnerabilityAssessmentScanRecordListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) vulnerabilityAssessmentScanRecordListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vasrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vasrlr.NextLink))) +} + +// VulnerabilityAssessmentScanRecordListResultPage contains a page of VulnerabilityAssessmentScanRecord +// values. +type VulnerabilityAssessmentScanRecordListResultPage struct { + fn func(context.Context, VulnerabilityAssessmentScanRecordListResult) (VulnerabilityAssessmentScanRecordListResult, error) + vasrlr VulnerabilityAssessmentScanRecordListResult +} + +// NextWithContext 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 *VulnerabilityAssessmentScanRecordListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VulnerabilityAssessmentScanRecordListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vasrlr) + if err != nil { + return err + } + page.vasrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VulnerabilityAssessmentScanRecordListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VulnerabilityAssessmentScanRecordListResultPage) NotDone() bool { + return !page.vasrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VulnerabilityAssessmentScanRecordListResultPage) Response() VulnerabilityAssessmentScanRecordListResult { + return page.vasrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VulnerabilityAssessmentScanRecordListResultPage) Values() []VulnerabilityAssessmentScanRecord { + if page.vasrlr.IsEmpty() { + return nil + } + return *page.vasrlr.Value +} + +// Creates a new instance of the VulnerabilityAssessmentScanRecordListResultPage type. +func NewVulnerabilityAssessmentScanRecordListResultPage(cur VulnerabilityAssessmentScanRecordListResult, getNextPage func(context.Context, VulnerabilityAssessmentScanRecordListResult) (VulnerabilityAssessmentScanRecordListResult, error)) VulnerabilityAssessmentScanRecordListResultPage { + return VulnerabilityAssessmentScanRecordListResultPage{ + fn: getNextPage, + vasrlr: cur, + } +} + +// VulnerabilityAssessmentScanRecordProperties properties of a vulnerability assessment scan record. +type VulnerabilityAssessmentScanRecordProperties struct { + // ScanID - READ-ONLY; The scan ID. + ScanID *string `json:"scanId,omitempty"` + // TriggerType - READ-ONLY; The scan trigger type. Possible values include: 'VulnerabilityAssessmentScanTriggerTypeOnDemand', 'VulnerabilityAssessmentScanTriggerTypeRecurring' + TriggerType VulnerabilityAssessmentScanTriggerType `json:"triggerType,omitempty"` + // State - READ-ONLY; The scan status. Possible values include: 'VulnerabilityAssessmentScanStatePassed', 'VulnerabilityAssessmentScanStateFailed', 'VulnerabilityAssessmentScanStateFailedToRun', 'VulnerabilityAssessmentScanStateInProgress' + State VulnerabilityAssessmentScanState `json:"state,omitempty"` + // StartTime - READ-ONLY; The scan start time (UTC). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The scan end time (UTC). + EndTime *date.Time `json:"endTime,omitempty"` + // Errors - READ-ONLY; The scan errors. + Errors *[]VulnerabilityAssessmentScanError `json:"errors,omitempty"` + // StorageContainerPath - READ-ONLY; The scan results storage container path. + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // NumberOfFailedSecurityChecks - READ-ONLY; The number of failed security checks. + NumberOfFailedSecurityChecks *int32 `json:"numberOfFailedSecurityChecks,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecordProperties. +func (vasrp VulnerabilityAssessmentScanRecordProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkloadClassifier workload classifier operations for a data warehouse +type WorkloadClassifier struct { + autorest.Response `json:"-"` + // WorkloadClassifierProperties - Resource properties. + *WorkloadClassifierProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadClassifier. +func (wc WorkloadClassifier) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wc.WorkloadClassifierProperties != nil { + objectMap["properties"] = wc.WorkloadClassifierProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadClassifier struct. +func (wc *WorkloadClassifier) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadClassifierProperties WorkloadClassifierProperties + err = json.Unmarshal(*v, &workloadClassifierProperties) + if err != nil { + return err + } + wc.WorkloadClassifierProperties = &workloadClassifierProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wc.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadClassifierListResult a list of workload classifiers for a workload group. +type WorkloadClassifierListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]WorkloadClassifier `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadClassifierListResult. +func (wclr WorkloadClassifierListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkloadClassifierListResultIterator provides access to a complete listing of WorkloadClassifier values. +type WorkloadClassifierListResultIterator struct { + i int + page WorkloadClassifierListResultPage +} + +// NextWithContext 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 *WorkloadClassifierListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifierListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadClassifierListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadClassifierListResultIterator) 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 WorkloadClassifierListResultIterator) Response() WorkloadClassifierListResult { + 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 WorkloadClassifierListResultIterator) Value() WorkloadClassifier { + if !iter.page.NotDone() { + return WorkloadClassifier{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadClassifierListResultIterator type. +func NewWorkloadClassifierListResultIterator(page WorkloadClassifierListResultPage) WorkloadClassifierListResultIterator { + return WorkloadClassifierListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wclr WorkloadClassifierListResult) IsEmpty() bool { + return wclr.Value == nil || len(*wclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wclr WorkloadClassifierListResult) hasNextLink() bool { + return wclr.NextLink != nil && len(*wclr.NextLink) != 0 +} + +// workloadClassifierListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wclr WorkloadClassifierListResult) workloadClassifierListResultPreparer(ctx context.Context) (*http.Request, error) { + if !wclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wclr.NextLink))) +} + +// WorkloadClassifierListResultPage contains a page of WorkloadClassifier values. +type WorkloadClassifierListResultPage struct { + fn func(context.Context, WorkloadClassifierListResult) (WorkloadClassifierListResult, error) + wclr WorkloadClassifierListResult +} + +// NextWithContext 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 *WorkloadClassifierListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifierListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wclr) + if err != nil { + return err + } + page.wclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadClassifierListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadClassifierListResultPage) NotDone() bool { + return !page.wclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadClassifierListResultPage) Response() WorkloadClassifierListResult { + return page.wclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadClassifierListResultPage) Values() []WorkloadClassifier { + if page.wclr.IsEmpty() { + return nil + } + return *page.wclr.Value +} + +// Creates a new instance of the WorkloadClassifierListResultPage type. +func NewWorkloadClassifierListResultPage(cur WorkloadClassifierListResult, getNextPage func(context.Context, WorkloadClassifierListResult) (WorkloadClassifierListResult, error)) WorkloadClassifierListResultPage { + return WorkloadClassifierListResultPage{ + fn: getNextPage, + wclr: cur, + } +} + +// WorkloadClassifierProperties workload classifier definition. For more information look at +// sys.workload_management_workload_classifiers (DMV). +type WorkloadClassifierProperties struct { + // MemberName - The workload classifier member name. + MemberName *string `json:"memberName,omitempty"` + // Label - The workload classifier label. + Label *string `json:"label,omitempty"` + // Context - The workload classifier context. + Context *string `json:"context,omitempty"` + // StartTime - The workload classifier start time for classification. + StartTime *string `json:"startTime,omitempty"` + // EndTime - The workload classifier end time for classification. + EndTime *string `json:"endTime,omitempty"` + // Importance - The workload classifier importance. + Importance *string `json:"importance,omitempty"` +} + +// WorkloadClassifiersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadClassifiersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadClassifiersClient) (WorkloadClassifier, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadClassifiersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadClassifiersCreateOrUpdateFuture.Result. +func (future *WorkloadClassifiersCreateOrUpdateFuture) result(client WorkloadClassifiersClient) (wc WorkloadClassifier, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadClassifiersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wc.Response.Response, err = future.GetResult(sender); err == nil && wc.Response.Response.StatusCode != http.StatusNoContent { + wc, err = client.CreateOrUpdateResponder(wc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersCreateOrUpdateFuture", "Result", wc.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadClassifiersDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadClassifiersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadClassifiersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadClassifiersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadClassifiersDeleteFuture.Result. +func (future *WorkloadClassifiersDeleteFuture) result(client WorkloadClassifiersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadClassifiersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadGroup workload group operations for a data warehouse +type WorkloadGroup struct { + autorest.Response `json:"-"` + // WorkloadGroupProperties - Resource properties. + *WorkloadGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadGroup. +func (wg WorkloadGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wg.WorkloadGroupProperties != nil { + objectMap["properties"] = wg.WorkloadGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadGroup struct. +func (wg *WorkloadGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadGroupProperties WorkloadGroupProperties + err = json.Unmarshal(*v, &workloadGroupProperties) + if err != nil { + return err + } + wg.WorkloadGroupProperties = &workloadGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wg.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadGroupListResult a list of workload groups. +type WorkloadGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]WorkloadGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadGroupListResult. +func (wglr WorkloadGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkloadGroupListResultIterator provides access to a complete listing of WorkloadGroup values. +type WorkloadGroupListResultIterator struct { + i int + page WorkloadGroupListResultPage +} + +// NextWithContext 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 *WorkloadGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadGroupListResultIterator) 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 WorkloadGroupListResultIterator) Response() WorkloadGroupListResult { + 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 WorkloadGroupListResultIterator) Value() WorkloadGroup { + if !iter.page.NotDone() { + return WorkloadGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadGroupListResultIterator type. +func NewWorkloadGroupListResultIterator(page WorkloadGroupListResultPage) WorkloadGroupListResultIterator { + return WorkloadGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wglr WorkloadGroupListResult) IsEmpty() bool { + return wglr.Value == nil || len(*wglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wglr WorkloadGroupListResult) hasNextLink() bool { + return wglr.NextLink != nil && len(*wglr.NextLink) != 0 +} + +// workloadGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wglr WorkloadGroupListResult) workloadGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !wglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wglr.NextLink))) +} + +// WorkloadGroupListResultPage contains a page of WorkloadGroup values. +type WorkloadGroupListResultPage struct { + fn func(context.Context, WorkloadGroupListResult) (WorkloadGroupListResult, error) + wglr WorkloadGroupListResult +} + +// NextWithContext 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 *WorkloadGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wglr) + if err != nil { + return err + } + page.wglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadGroupListResultPage) NotDone() bool { + return !page.wglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadGroupListResultPage) Response() WorkloadGroupListResult { + return page.wglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadGroupListResultPage) Values() []WorkloadGroup { + if page.wglr.IsEmpty() { + return nil + } + return *page.wglr.Value +} + +// Creates a new instance of the WorkloadGroupListResultPage type. +func NewWorkloadGroupListResultPage(cur WorkloadGroupListResult, getNextPage func(context.Context, WorkloadGroupListResult) (WorkloadGroupListResult, error)) WorkloadGroupListResultPage { + return WorkloadGroupListResultPage{ + fn: getNextPage, + wglr: cur, + } +} + +// WorkloadGroupProperties workload group definition. For more information look at +// sys.workload_management_workload_groups (DMV). +type WorkloadGroupProperties struct { + // MinResourcePercent - The workload group minimum percentage resource. + MinResourcePercent *int32 `json:"minResourcePercent,omitempty"` + // MaxResourcePercent - The workload group cap percentage resource. + MaxResourcePercent *int32 `json:"maxResourcePercent,omitempty"` + // MinResourcePercentPerRequest - The workload group request minimum grant percentage. + MinResourcePercentPerRequest *float64 `json:"minResourcePercentPerRequest,omitempty"` + // MaxResourcePercentPerRequest - The workload group request maximum grant percentage. + MaxResourcePercentPerRequest *float64 `json:"maxResourcePercentPerRequest,omitempty"` + // Importance - The workload group importance level. + Importance *string `json:"importance,omitempty"` + // QueryExecutionTimeout - The workload group query execution timeout. + QueryExecutionTimeout *int32 `json:"queryExecutionTimeout,omitempty"` +} + +// WorkloadGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadGroupsClient) (WorkloadGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadGroupsCreateOrUpdateFuture.Result. +func (future *WorkloadGroupsCreateOrUpdateFuture) result(client WorkloadGroupsClient) (wg WorkloadGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wg.Response.Response, err = future.GetResult(sender); err == nil && wg.Response.Response.StatusCode != http.StatusNoContent { + wg, err = client.CreateOrUpdateResponder(wg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsCreateOrUpdateFuture", "Result", wg.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type WorkloadGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadGroupsDeleteFuture.Result. +func (future *WorkloadGroupsDeleteFuture) result(client WorkloadGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/operations.go b/services/preview/sql/mgmt/v3.0/sql/operations.go new file mode 100644 index 000000000000..8d4ac613b1ce --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/operations.go @@ -0,0 +1,142 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// OperationsClient 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 OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available SQL Rest API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Sql/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/privateendpointconnections.go b/services/preview/sql/mgmt/v3.0/sql/privateendpointconnections.go new file mode 100644 index 000000000000..9fcd87b43a29 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/privateendpointconnections.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient 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 PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("sql.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-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}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "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.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-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}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all private endpoint connections on a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client PrivateEndpointConnectionsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByServer") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client PrivateEndpointConnectionsClient) 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 = "2020-11-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}/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByServerResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + 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 PrivateEndpointConnectionsClient) listByServerNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "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.PrivateEndpointConnectionsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/privatelinkresources.go b/services/preview/sql/mgmt/v3.0/sql/privatelinkresources.go new file mode 100644 index 000000000000..3bc307c1f05a --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/privatelinkresources.go @@ -0,0 +1,232 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// PrivateLinkResourcesClient 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 PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource for SQL server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// groupName - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, serverName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "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.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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}/privateLinkResources/{groupName}", 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 PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets the private link resources for SQL server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client PrivateLinkResourcesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result PrivateLinkResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByServer") + defer func() { + sc := -1 + if result.plrlr.Response.Response != nil { + sc = result.plrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.plrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.plrlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.plrlr.hasNextLink() && result.plrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client PrivateLinkResourcesClient) 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 = "2018-06-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}/privateLinkResources", 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 PrivateLinkResourcesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByServerResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + 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 PrivateLinkResourcesClient) listByServerNextResults(ctx context.Context, lastResults PrivateLinkResourceListResult) (result PrivateLinkResourceListResult, err error) { + req, err := lastResults.privateLinkResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "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.PrivateLinkResourcesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result PrivateLinkResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/recommendedelasticpools.go b/services/preview/sql/mgmt/v3.0/sql/recommendedelasticpools.go new file mode 100644 index 000000000000..8e0f5d7c5f24 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/recommendedelasticpools.go @@ -0,0 +1,269 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RecommendedElasticPoolsClient 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 RecommendedElasticPoolsClient struct { + BaseClient +} + +// NewRecommendedElasticPoolsClient creates an instance of the RecommendedElasticPoolsClient client. +func NewRecommendedElasticPoolsClient(subscriptionID string) RecommendedElasticPoolsClient { + return NewRecommendedElasticPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecommendedElasticPoolsClientWithBaseURI creates an instance of the RecommendedElasticPoolsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRecommendedElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) RecommendedElasticPoolsClient { + return RecommendedElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recommended elastic pool. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// recommendedElasticPoolName - the name of the recommended elastic pool to be retrieved. +func (client RecommendedElasticPoolsClient) Get(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (result RecommendedElasticPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendedElasticPoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, recommendedElasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "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.RecommendedElasticPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecommendedElasticPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recommendedElasticPoolName": autorest.Encode("path", recommendedElasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/recommendedElasticPools/{recommendedElasticPoolName}", 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 RecommendedElasticPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecommendedElasticPoolsClient) GetResponder(resp *http.Response) (result RecommendedElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns recommended elastic pools. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client RecommendedElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RecommendedElasticPoolListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendedElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RecommendedElasticPoolsClient) 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 = "2014-04-01" + 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}/recommendedElasticPools", 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 RecommendedElasticPoolsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecommendedElasticPoolsClient) ListByServerResponder(resp *http.Response) (result RecommendedElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns recommended elastic pool metrics. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// recommendedElasticPoolName - the name of the recommended elastic pool to be retrieved. +func (client RecommendedElasticPoolsClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (result RecommendedElasticPoolListMetricsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendedElasticPoolsClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, recommendedElasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedElasticPoolsClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client RecommendedElasticPoolsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recommendedElasticPoolName": autorest.Encode("path", recommendedElasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/recommendedElasticPools/{recommendedElasticPoolName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendedElasticPoolsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client RecommendedElasticPoolsClient) ListMetricsResponder(resp *http.Response) (result RecommendedElasticPoolListMetricsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/recoverabledatabases.go b/services/preview/sql/mgmt/v3.0/sql/recoverabledatabases.go new file mode 100644 index 000000000000..ef56a498903f --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/recoverabledatabases.go @@ -0,0 +1,190 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RecoverableDatabasesClient 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 RecoverableDatabasesClient struct { + BaseClient +} + +// NewRecoverableDatabasesClient creates an instance of the RecoverableDatabasesClient client. +func NewRecoverableDatabasesClient(subscriptionID string) RecoverableDatabasesClient { + return NewRecoverableDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableDatabasesClientWithBaseURI creates an instance of the RecoverableDatabasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewRecoverableDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RecoverableDatabasesClient { + return RecoverableDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable database, which is a resource representing a database's geo backup +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database +func (client RecoverableDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RecoverableDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "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.RecoverableDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableDatabasesClient) 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 = "2014-04-01" + 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}/recoverableDatabases/{databaseName}", 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 RecoverableDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) GetResponder(resp *http.Response) (result RecoverableDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of recoverable databases +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client RecoverableDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RecoverableDatabasesClient) 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 = "2014-04-01" + 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}/recoverableDatabases", 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 RecoverableDatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) ListByServerResponder(resp *http.Response) (result RecoverableDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/recoverablemanageddatabases.go b/services/preview/sql/mgmt/v3.0/sql/recoverablemanageddatabases.go new file mode 100644 index 000000000000..e6519d2d5a1d --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/recoverablemanageddatabases.go @@ -0,0 +1,231 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RecoverableManagedDatabasesClient 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 RecoverableManagedDatabasesClient struct { + BaseClient +} + +// NewRecoverableManagedDatabasesClient creates an instance of the RecoverableManagedDatabasesClient client. +func NewRecoverableManagedDatabasesClient(subscriptionID string) RecoverableManagedDatabasesClient { + return NewRecoverableManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableManagedDatabasesClientWithBaseURI creates an instance of the RecoverableManagedDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRecoverableManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RecoverableManagedDatabasesClient { + return RecoverableManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RecoverableManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (result RecoverableManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, recoverableDatabaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "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.RecoverableManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "recoverableDatabaseName": autorest.Encode("path", recoverableDatabaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}", 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 RecoverableManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableManagedDatabasesClient) GetResponder(resp *http.Response) (result RecoverableManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of recoverable managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RecoverableManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RecoverableManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.rmdlr.Response.Response != nil { + sc = result.rmdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.rmdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.rmdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.rmdlr.hasNextLink() && result.rmdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client RecoverableManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-10-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/managedInstances/{managedInstanceName}/recoverableDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client RecoverableManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client RecoverableManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result RecoverableManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client RecoverableManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults RecoverableManagedDatabaseListResult) (result RecoverableManagedDatabaseListResult, err error) { + req, err := lastResults.recoverableManagedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecoverableManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RecoverableManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/replicationlinks.go b/services/preview/sql/mgmt/v3.0/sql/replicationlinks.go new file mode 100644 index 000000000000..861e0db43427 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/replicationlinks.go @@ -0,0 +1,527 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ReplicationLinksClient 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 ReplicationLinksClient struct { + BaseClient +} + +// NewReplicationLinksClient creates an instance of the ReplicationLinksClient client. +func NewReplicationLinksClient(subscriptionID string) ReplicationLinksClient { + return NewReplicationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReplicationLinksClientWithBaseURI creates an instance of the ReplicationLinksClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewReplicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ReplicationLinksClient { + return ReplicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a database replication link. Cannot be done during failover. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be dropped. +// linkID - the ID of the replication link to be deleted. +func (client ReplicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/databases/{databaseName}/replicationLinks/{linkId}", 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 ReplicationLinksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover sets which replica database is primary by failing over from the current primary replica database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +func (client ReplicationLinksClient) Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Failover", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ReplicationLinksClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/databases/{databaseName}/replicationLinks/{linkId}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) FailoverSender(req *http.Request) (future ReplicationLinksFailoverFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverAllowDataLoss sets which replica database is primary by failing over from the current primary replica +// database. This operation might result in data loss. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +func (client ReplicationLinksClient) FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.FailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverAllowDataLossPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "FailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.FailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "FailoverAllowDataLoss", result.Response(), "Failure sending request") + return + } + + return +} + +// FailoverAllowDataLossPreparer prepares the FailoverAllowDataLoss request. +func (client ReplicationLinksClient) FailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverAllowDataLossSender sends the FailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) FailoverAllowDataLossSender(req *http.Request) (future ReplicationLinksFailoverAllowDataLossFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverAllowDataLossResponder handles the response to the FailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) FailoverAllowDataLossResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database replication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to get the link for. +// linkID - the replication link ID to be retrieved. +func (client ReplicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "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.ReplicationLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/replicationLinks/{linkId}", 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 ReplicationLinksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) GetResponder(resp *http.Response) (result ReplicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists a database's replication links. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database to retrieve links for. +func (client ReplicationLinksClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ReplicationLinksClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/replicationLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) ListByDatabaseResponder(resp *http.Response) (result ReplicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Unlink deletes a database replication link in forced or friendly way. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +// parameters - the required parameters for unlinking replication link. +func (client ReplicationLinksClient) Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (result ReplicationLinksUnlinkFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Unlink") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UnlinkPreparer(ctx, resourceGroupName, serverName, databaseName, linkID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", nil, "Failure preparing request") + return + } + + result, err = client.UnlinkSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", result.Response(), "Failure sending request") + return + } + + return +} + +// UnlinkPreparer prepares the Unlink request. +func (client ReplicationLinksClient) UnlinkPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UnlinkSender sends the Unlink request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) UnlinkSender(req *http.Request) (future ReplicationLinksUnlinkFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UnlinkResponder handles the response to the Unlink request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) UnlinkResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/restorabledroppeddatabases.go b/services/preview/sql/mgmt/v3.0/sql/restorabledroppeddatabases.go new file mode 100644 index 000000000000..7298ef0b736f --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/restorabledroppeddatabases.go @@ -0,0 +1,191 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RestorableDroppedDatabasesClient 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 RestorableDroppedDatabasesClient struct { + BaseClient +} + +// NewRestorableDroppedDatabasesClient creates an instance of the RestorableDroppedDatabasesClient client. +func NewRestorableDroppedDatabasesClient(subscriptionID string) RestorableDroppedDatabasesClient { + return NewRestorableDroppedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDroppedDatabasesClientWithBaseURI creates an instance of the RestorableDroppedDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableDroppedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedDatabasesClient { + return RestorableDroppedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a deleted database that can be restored +// Parameters: +// resourceGroupName - 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 - the name of the server. +// restorableDroppededDatabaseID - the id of the deleted database in the form of +// databaseName,deletionTimeInFileTimeFormat +func (client RestorableDroppedDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppededDatabaseID string) (result RestorableDroppedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, restorableDroppededDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "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.RestorableDroppedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorableDroppedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, restorableDroppededDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppededDatabaseId": autorest.Encode("path", restorableDroppededDatabaseID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/restorableDroppedDatabases/{restorableDroppededDatabaseId}", 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 RestorableDroppedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of deleted databases that can be restored +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client RestorableDroppedDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RestorableDroppedDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RestorableDroppedDatabasesClient) 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 = "2014-04-01" + 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}/restorableDroppedDatabases", 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 RestorableDroppedDatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) ListByServerResponder(resp *http.Response) (result RestorableDroppedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/restorabledroppedmanageddatabases.go b/services/preview/sql/mgmt/v3.0/sql/restorabledroppedmanageddatabases.go new file mode 100644 index 000000000000..38d174e46d1e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/restorabledroppedmanageddatabases.go @@ -0,0 +1,232 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// RestorableDroppedManagedDatabasesClient 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 RestorableDroppedManagedDatabasesClient struct { + BaseClient +} + +// NewRestorableDroppedManagedDatabasesClient creates an instance of the RestorableDroppedManagedDatabasesClient +// client. +func NewRestorableDroppedManagedDatabasesClient(subscriptionID string) RestorableDroppedManagedDatabasesClient { + return NewRestorableDroppedManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDroppedManagedDatabasesClientWithBaseURI creates an instance of the +// RestorableDroppedManagedDatabasesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRestorableDroppedManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedManagedDatabasesClient { + return RestorableDroppedManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a restorable dropped managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RestorableDroppedManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result RestorableDroppedManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "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.RestorableDroppedManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorableDroppedManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "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/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}", 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 RestorableDroppedManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedManagedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of restorable dropped managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RestorableDroppedManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RestorableDroppedManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.rdmdlr.Response.Response != nil { + sc = result.rdmdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.rdmdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.rdmdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.rdmdlr.hasNextLink() && result.rdmdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client RestorableDroppedManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/managedInstances/{managedInstanceName}/restorableDroppedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDroppedManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client RestorableDroppedManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result RestorableDroppedManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client RestorableDroppedManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults RestorableDroppedManagedDatabaseListResult) (result RestorableDroppedManagedDatabaseListResult, err error) { + req, err := lastResults.restorableDroppedManagedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RestorableDroppedManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RestorableDroppedManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/restorepoints.go b/services/preview/sql/mgmt/v3.0/sql/restorepoints.go new file mode 100644 index 000000000000..6637ed2cccfb --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/restorepoints.go @@ -0,0 +1,365 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorePointsClient 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 RestorePointsClient struct { + BaseClient +} + +// NewRestorePointsClient creates an instance of the RestorePointsClient client. +func NewRestorePointsClient(subscriptionID string) RestorePointsClient { + return NewRestorePointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorePointsClientWithBaseURI creates an instance of the RestorePointsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRestorePointsClientWithBaseURI(baseURI string, subscriptionID string) RestorePointsClient { + return RestorePointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a restore point for a data warehouse. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the definition for creating the restore point of this database. +func (client RestorePointsClient) Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters CreateDatabaseRestorePointDefinition) (result RestorePointsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RestorePointLabel", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.RestorePointsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client RestorePointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters CreateDatabaseRestorePointDefinition) (*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 = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints", pathParameters), + autorest.WithJSON(parameters), + 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 RestorePointsClient) CreateSender(req *http.Request) (future RestorePointsCreateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) CreateResponder(resp *http.Response) (result RestorePoint, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a restore point. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// restorePointName - the name of the restore point. +func (client RestorePointsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, restorePointName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RestorePointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorePointName": autorest.Encode("path", restorePointName), + "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}/databases/{databaseName}/restorePoints/{restorePointName}", 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 RestorePointsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a restore point. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// restorePointName - the name of the restore point. +func (client RestorePointsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result RestorePoint, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, restorePointName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "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.RestorePointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorePointsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorePointName": autorest.Encode("path", restorePointName), + "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}/databases/{databaseName}/restorePoints/{restorePointName}", 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 RestorePointsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) GetResponder(resp *http.Response) (result RestorePoint, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database restore points. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client RestorePointsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RestorePointListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client RestorePointsClient) ListByDatabasePreparer(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 = "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}/databases/{databaseName}/restorePoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client RestorePointsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) ListByDatabaseResponder(resp *http.Response) (result RestorePointListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/sensitivitylabels.go b/services/preview/sql/mgmt/v3.0/sql/sensitivitylabels.go new file mode 100644 index 000000000000..71a896aaaa88 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/sensitivitylabels.go @@ -0,0 +1,723 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SensitivityLabelsClient 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 SensitivityLabelsClient struct { + BaseClient +} + +// NewSensitivityLabelsClient creates an instance of the SensitivityLabelsClient client. +func NewSensitivityLabelsClient(subscriptionID string) SensitivityLabelsClient { + return NewSensitivityLabelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSensitivityLabelsClientWithBaseURI creates an instance of the SensitivityLabelsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSensitivityLabelsClientWithBaseURI(baseURI string, subscriptionID string) SensitivityLabelsClient { + return SensitivityLabelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the sensitivity label of a given column +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// parameters - the column sensitivity label resource. +func (client SensitivityLabelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "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.SensitivityLabelsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SensitivityLabelsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", 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 SensitivityLabelsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) CreateOrUpdateResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the sensitivity label of a given column +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client SensitivityLabelsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SensitivityLabelsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + 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}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", 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 SensitivityLabelsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DisableRecommendation disables sensitivity recommendations on a given column +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client SensitivityLabelsClient) DisableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.DisableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DisableRecommendationPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "DisableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.DisableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "DisableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.DisableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "DisableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// DisableRecommendationPreparer prepares the DisableRecommendation request. +func (client SensitivityLabelsClient) DisableRecommendationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + 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}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisableRecommendationSender sends the DisableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) DisableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DisableRecommendationResponder handles the response to the DisableRecommendation request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) DisableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableRecommendation enables sensitivity recommendations on a given column (recommendations are enabled by default +// on all columns) +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client SensitivityLabelsClient) EnableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.EnableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.EnableRecommendationPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "EnableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.EnableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "EnableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.EnableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "EnableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// EnableRecommendationPreparer prepares the EnableRecommendation request. +func (client SensitivityLabelsClient) EnableRecommendationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + 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}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableRecommendationSender sends the EnableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) EnableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// EnableRecommendationResponder handles the response to the EnableRecommendation request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) EnableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the sensitivity label of a given column +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// sensitivityLabelSource - the source of the sensitivity label. +func (client SensitivityLabelsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName, sensitivityLabelSource) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "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.SensitivityLabelsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SensitivityLabelsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", sensitivityLabelSource), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + 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}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", 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 SensitivityLabelsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) GetResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCurrentByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// filter - an OData filter expression that filters elements in the collection. +func (client SensitivityLabelsClient) ListCurrentByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listCurrentByDatabaseNextResults + req, err := client.ListCurrentByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListCurrentByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListCurrentByDatabasePreparer prepares the ListCurrentByDatabase request. +func (client SensitivityLabelsClient) ListCurrentByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter 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 = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCurrentByDatabaseSender sends the ListCurrentByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) ListCurrentByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCurrentByDatabaseResponder handles the response to the ListCurrentByDatabase request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) ListCurrentByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listCurrentByDatabaseNextResults retrieves the next set of results, if any. +func (client SensitivityLabelsClient) listCurrentByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listCurrentByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListCurrentByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SensitivityLabelsClient) ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListCurrentByDatabase(ctx, resourceGroupName, serverName, databaseName, filter) + return +} + +// ListRecommendedByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// includeDisabledRecommendations - specifies whether to include disabled recommendations or not. +// filter - an OData filter expression that filters elements in the collection. +func (client SensitivityLabelsClient) ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listRecommendedByDatabaseNextResults + req, err := client.ListRecommendedByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, includeDisabledRecommendations, skipToken, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListRecommendedByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListRecommendedByDatabasePreparer prepares the ListRecommendedByDatabase request. +func (client SensitivityLabelsClient) ListRecommendedByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter 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 = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if includeDisabledRecommendations != nil { + queryParameters["includeDisabledRecommendations"] = autorest.Encode("query", *includeDisabledRecommendations) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListRecommendedByDatabaseSender sends the ListRecommendedByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) ListRecommendedByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListRecommendedByDatabaseResponder handles the response to the ListRecommendedByDatabase request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) ListRecommendedByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listRecommendedByDatabaseNextResults retrieves the next set of results, if any. +func (client SensitivityLabelsClient) listRecommendedByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listRecommendedByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRecommendedByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SensitivityLabelsClient) ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListRecommendedByDatabase(ctx, resourceGroupName, serverName, databaseName, includeDisabledRecommendations, skipToken, filter) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverautomatictuning.go b/services/preview/sql/mgmt/v3.0/sql/serverautomatictuning.go new file mode 100644 index 000000000000..6d0fd7679702 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverautomatictuning.go @@ -0,0 +1,191 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "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 using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewServerAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) ServerAutomaticTuningClient { + return ServerAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieves server automatic tuning options. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAutomaticTuningClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning options on server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested automatic tuning resource state. +func (client ServerAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (result ServerAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAutomaticTuningClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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 + } + + 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.AsContentType("application/json; charset=utf-8"), + 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 client.Send(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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverazureadadministrators.go b/services/preview/sql/mgmt/v3.0/sql/serverazureadadministrators.go new file mode 100644 index 000000000000..8db20d8beb28 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverazureadadministrators.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAzureADAdministratorsClient 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 ServerAzureADAdministratorsClient struct { + BaseClient +} + +// NewServerAzureADAdministratorsClient creates an instance of the ServerAzureADAdministratorsClient client. +func NewServerAzureADAdministratorsClient(subscriptionID string) ServerAzureADAdministratorsClient { + return NewServerAzureADAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAzureADAdministratorsClientWithBaseURI creates an instance of the ServerAzureADAdministratorsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerAzureADAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ServerAzureADAdministratorsClient { + return ServerAzureADAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing Azure Active Directory administrator. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested Azure Active Directory administrator Resource state. +func (client ServerAzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADAdministrator) (result ServerAzureADAdministratorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AdministratorProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorProperties.Login", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorProperties.Sid", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerAzureADAdministratorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADAdministrator) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", 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 ServerAzureADAdministratorsClient) CreateOrUpdateSender(req *http.Request) (future ServerAzureADAdministratorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the Azure Active Directory administrator with the given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministratorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerAzureADAdministratorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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}/administrators/{administratorName}", 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 ServerAzureADAdministratorsClient) DeleteSender(req *http.Request) (future ServerAzureADAdministratorsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Azure Active Directory administrator. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministrator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "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.ServerAzureADAdministratorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAzureADAdministratorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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}/administrators/{administratorName}", 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 ServerAzureADAdministratorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) GetResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of Azure Active Directory administrators in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADAdministratorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result AdministratorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.ListByServer") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.alr.hasNextLink() && result.alr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAzureADAdministratorsClient) 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 = "2019-06-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}/administrators", 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 ServerAzureADAdministratorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) ListByServerResponder(resp *http.Response) (result AdministratorListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerAzureADAdministratorsClient) listByServerNextResults(ctx context.Context, lastResults AdministratorListResult) (result AdministratorListResult, err error) { + req, err := lastResults.administratorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "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.ServerAzureADAdministratorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerAzureADAdministratorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result AdministratorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverazureadonlyauthentications.go b/services/preview/sql/mgmt/v3.0/sql/serverazureadonlyauthentications.go new file mode 100644 index 000000000000..693e7671b543 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverazureadonlyauthentications.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAzureADOnlyAuthenticationsClient 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 ServerAzureADOnlyAuthenticationsClient struct { + BaseClient +} + +// NewServerAzureADOnlyAuthenticationsClient creates an instance of the ServerAzureADOnlyAuthenticationsClient client. +func NewServerAzureADOnlyAuthenticationsClient(subscriptionID string) ServerAzureADOnlyAuthenticationsClient { + return NewServerAzureADOnlyAuthenticationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAzureADOnlyAuthenticationsClientWithBaseURI creates an instance of the +// ServerAzureADOnlyAuthenticationsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerAzureADOnlyAuthenticationsClientWithBaseURI(baseURI string, subscriptionID string) ServerAzureADOnlyAuthenticationsClient { + return ServerAzureADOnlyAuthenticationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets Server Active Directory only authentication property or updates an existing server Active +// Directory only authentication property. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the required parameters for creating or updating an Active Directory only authentication +// property. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADOnlyAuthentication) (result ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AzureADOnlyAuthProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AzureADOnlyAuthProperties.AzureADOnlyAuthentication", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerAzureADOnlyAuthenticationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADOnlyAuthentication) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", 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 ServerAzureADOnlyAuthenticationsClient) CreateOrUpdateSender(req *http.Request) (future ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory only authentication property. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADOnlyAuthenticationsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADOnlyAuthenticationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerAzureADOnlyAuthenticationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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}/azureADOnlyAuthentications/{authenticationName}", 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 ServerAzureADOnlyAuthenticationsClient) DeleteSender(req *http.Request) (future ServerAzureADOnlyAuthenticationsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a specific Azure Active Directory only authentication property. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADOnlyAuthenticationsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADOnlyAuthentication, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "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.ServerAzureADOnlyAuthenticationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAzureADOnlyAuthenticationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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}/azureADOnlyAuthentications/{authenticationName}", 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 ServerAzureADOnlyAuthenticationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) GetResponder(resp *http.Response) (result ServerAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server Azure Active Directory only authentications. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result AzureADOnlyAuthListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.ListByServer") + defer func() { + sc := -1 + if result.aaoalr.Response.Response != nil { + sc = result.aaoalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.aaoalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.aaoalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.aaoalr.hasNextLink() && result.aaoalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAzureADOnlyAuthenticationsClient) 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 = "2020-02-02-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}/azureADOnlyAuthentications", 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 ServerAzureADOnlyAuthenticationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServerResponder(resp *http.Response) (result AzureADOnlyAuthListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerAzureADOnlyAuthenticationsClient) listByServerNextResults(ctx context.Context, lastResults AzureADOnlyAuthListResult) (result AzureADOnlyAuthListResult, err error) { + req, err := lastResults.azureADOnlyAuthListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "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.ServerAzureADOnlyAuthenticationsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result AzureADOnlyAuthListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverblobauditingpolicies.go b/services/preview/sql/mgmt/v3.0/sql/serverblobauditingpolicies.go new file mode 100644 index 000000000000..3983f9e6a879 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverblobauditingpolicies.go @@ -0,0 +1,315 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerBlobAuditingPoliciesClient 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 ServerBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewServerBlobAuditingPoliciesClient creates an instance of the ServerBlobAuditingPoliciesClient client. +func NewServerBlobAuditingPoliciesClient(subscriptionID string) ServerBlobAuditingPoliciesClient { + return NewServerBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerBlobAuditingPoliciesClientWithBaseURI creates an instance of the ServerBlobAuditingPoliciesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerBlobAuditingPoliciesClient { + return ServerBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - properties of blob auditing policy +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerBlobAuditingPolicy) (result ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}", 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 ServerBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server's blob auditing policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "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.ServerBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "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}/auditingSettings/{blobAuditingPolicyName}", 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 ServerBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result ServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists auditing settings of a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerBlobAuditingPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.sbaplr.Response.Response != nil { + sc = result.sbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sbaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sbaplr.hasNextLink() && result.sbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerBlobAuditingPoliciesClient) 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}/auditingSettings", 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 ServerBlobAuditingPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerBlobAuditingPoliciesClient) ListByServerResponder(resp *http.Response) (result ServerBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerBlobAuditingPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ServerBlobAuditingPolicyListResult) (result ServerBlobAuditingPolicyListResult, err error) { + req, err := lastResults.serverBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "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.ServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerBlobAuditingPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/servercommunicationlinks.go b/services/preview/sql/mgmt/v3.0/sql/servercommunicationlinks.go new file mode 100644 index 000000000000..cb24bd7204fc --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/servercommunicationlinks.go @@ -0,0 +1,363 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerCommunicationLinksClient 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 ServerCommunicationLinksClient struct { + BaseClient +} + +// NewServerCommunicationLinksClient creates an instance of the ServerCommunicationLinksClient client. +func NewServerCommunicationLinksClient(subscriptionID string) ServerCommunicationLinksClient { + return NewServerCommunicationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerCommunicationLinksClientWithBaseURI creates an instance of the ServerCommunicationLinksClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerCommunicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServerCommunicationLinksClient { + return ServerCommunicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a server communication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// communicationLinkName - the name of the server communication link. +// parameters - the required parameters for creating a server communication link. +func (client ServerCommunicationLinksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters ServerCommunicationLink) (result ServerCommunicationLinksCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerCommunicationLinkProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerCommunicationLinkProperties.PartnerServer", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerCommunicationLinksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, communicationLinkName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerCommunicationLinksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters ServerCommunicationLink) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", 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 ServerCommunicationLinksClient) CreateOrUpdateSender(req *http.Request) (future ServerCommunicationLinksCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) CreateOrUpdateResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server communication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// communicationLinkName - the name of the server communication link. +func (client ServerCommunicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, communicationLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerCommunicationLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/communicationLinks/{communicationLinkName}", 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 ServerCommunicationLinksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a server communication link. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// communicationLinkName - the name of the server communication link. +func (client ServerCommunicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result ServerCommunicationLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, communicationLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "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.ServerCommunicationLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerCommunicationLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/communicationLinks/{communicationLinkName}", 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 ServerCommunicationLinksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) GetResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server communication links. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerCommunicationLinksClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerCommunicationLinkListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerCommunicationLinksClient) 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 = "2014-04-01" + 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}/communicationLinks", 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 ServerCommunicationLinksClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) ListByServerResponder(resp *http.Response) (result ServerCommunicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverconnectionpolicies.go b/services/preview/sql/mgmt/v3.0/sql/serverconnectionpolicies.go new file mode 100644 index 000000000000..fd714db39b75 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverconnectionpolicies.go @@ -0,0 +1,195 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerConnectionPoliciesClient 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 ServerConnectionPoliciesClient struct { + BaseClient +} + +// NewServerConnectionPoliciesClient creates an instance of the ServerConnectionPoliciesClient client. +func NewServerConnectionPoliciesClient(subscriptionID string) ServerConnectionPoliciesClient { + return NewServerConnectionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerConnectionPoliciesClientWithBaseURI creates an instance of the ServerConnectionPoliciesClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerConnectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerConnectionPoliciesClient { + return ServerConnectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's connection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the required parameters for updating a secure connection policy. +func (client ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (result ServerConnectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "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.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerConnectionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", 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 ServerConnectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the server's secure connection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerConnectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "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.ServerConnectionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerConnectionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/connectionPolicies/{connectionPolicyName}", 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 ServerConnectionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) GetResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverdnsaliases.go b/services/preview/sql/mgmt/v3.0/sql/serverdnsaliases.go new file mode 100644 index 000000000000..8304dd7bfbbe --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverdnsaliases.go @@ -0,0 +1,478 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerDNSAliasesClient 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 ServerDNSAliasesClient struct { + BaseClient +} + +// NewServerDNSAliasesClient creates an instance of the ServerDNSAliasesClient client. +func NewServerDNSAliasesClient(subscriptionID string) ServerDNSAliasesClient { + return NewServerDNSAliasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerDNSAliasesClientWithBaseURI creates an instance of the ServerDNSAliasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServerDNSAliasesClientWithBaseURI(baseURI string, subscriptionID string) ServerDNSAliasesClient { + return ServerDNSAliasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Acquire acquires server DNS alias from another server. +// Parameters: +// resourceGroupName - 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 - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server dns alias. +func (client ServerDNSAliasesClient) Acquire(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string, parameters ServerDNSAliasAcquisition) (result ServerDNSAliasesAcquireFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.Acquire") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.AcquirePreparer(ctx, resourceGroupName, serverName, DNSAliasName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Acquire", nil, "Failure preparing request") + return + } + + result, err = client.AcquireSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Acquire", result.Response(), "Failure sending request") + return + } + + return +} + +// AcquirePreparer prepares the Acquire request. +func (client ServerDNSAliasesClient) AcquirePreparer(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string, parameters ServerDNSAliasAcquisition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AcquireSender sends the Acquire request. The method will close the +// http.Response Body if it receives an error. +func (client ServerDNSAliasesClient) AcquireSender(req *http.Request) (future ServerDNSAliasesAcquireFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// AcquireResponder handles the response to the Acquire request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) AcquireResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates a server dns alias. +// Parameters: +// resourceGroupName - 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 - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server DNS alias. +func (client ServerDNSAliasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAliasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerDNSAliasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "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}/dnsAliases/{dnsAliasName}", 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 ServerDNSAliasesClient) CreateOrUpdateSender(req *http.Request) (future ServerDNSAliasesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server DNS alias with the given name. +// Parameters: +// resourceGroupName - 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 - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server DNS alias. +func (client ServerDNSAliasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAliasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerDNSAliasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "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}/dnsAliases/{dnsAliasName}", 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 ServerDNSAliasesClient) DeleteSender(req *http.Request) (future ServerDNSAliasesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server DNS alias. +// Parameters: +// resourceGroupName - 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 - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server DNS alias. +func (client ServerDNSAliasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAlias, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "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.ServerDNSAliasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerDNSAliasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "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}/dnsAliases/{dnsAliasName}", 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 ServerDNSAliasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) GetResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server DNS aliases for a server. +// Parameters: +// resourceGroupName - 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 - the name of the server that the alias is pointing to. +func (client ServerDNSAliasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerDNSAliasListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.ListByServer") + defer func() { + sc := -1 + if result.sdalr.Response.Response != nil { + sc = result.sdalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sdalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sdalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sdalr.hasNextLink() && result.sdalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerDNSAliasesClient) 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}/dnsAliases", 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 ServerDNSAliasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) ListByServerResponder(resp *http.Response) (result ServerDNSAliasListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerDNSAliasesClient) listByServerNextResults(ctx context.Context, lastResults ServerDNSAliasListResult) (result ServerDNSAliasListResult, err error) { + req, err := lastResults.serverDNSAliasListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "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.ServerDNSAliasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerDNSAliasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerDNSAliasListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverkeys.go b/services/preview/sql/mgmt/v3.0/sql/serverkeys.go new file mode 100644 index 000000000000..54c560060bb9 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverkeys.go @@ -0,0 +1,401 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerKeysClient 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 ServerKeysClient struct { + BaseClient +} + +// NewServerKeysClient creates an instance of the ServerKeysClient client. +func NewServerKeysClient(subscriptionID string) ServerKeysClient { + return NewServerKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerKeysClientWithBaseURI creates an instance of the ServerKeysClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerKeysClientWithBaseURI(baseURI string, subscriptionID string) ServerKeysClient { + return ServerKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server key. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// keyName - the name of the server key to be operated on (updated or created). The key name is required to be +// in the format of 'vault_key_version'. For example, if the keyId is +// https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901, then the server key +// name should be formatted as: YourVaultName_YourKeyName_01234567890123456789012345678901 +// parameters - the requested server key resource state. +func (client ServerKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters ServerKey) (result ServerKeysCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerKeysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters ServerKey) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "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, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", 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 ServerKeysClient) CreateOrUpdateSender(req *http.Request) (future ServerKeysCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server key with the given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// keyName - the name of the server key to be deleted. +func (client ServerKeysClient) Delete(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result ServerKeysDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "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.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", 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 ServerKeysClient) DeleteSender(req *http.Request) (future ServerKeysDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server key. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// keyName - the name of the server key to be retrieved. +func (client ServerKeysClient) Get(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result ServerKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "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.ServerKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "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}/keys/{keyName}", 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 ServerKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) GetResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server keys. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerKeysClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.ListByServer") + defer func() { + sc := -1 + if result.sklr.Response.Response != nil { + sc = result.sklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sklr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sklr.hasNextLink() && result.sklr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerKeysClient) 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 = "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}/keys", 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 ServerKeysClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) ListByServerResponder(resp *http.Response) (result ServerKeyListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerKeysClient) listByServerNextResults(ctx context.Context, lastResults ServerKeyListResult) (result ServerKeyListResult, err error) { + req, err := lastResults.serverKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerKeysClient", "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.ServerKeysClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerKeysClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/servers.go b/services/preview/sql/mgmt/v3.0/sql/servers.go new file mode 100644 index 000000000000..021195c9ab5e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/servers.go @@ -0,0 +1,761 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServersClient 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 ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability determines whether a resource can be created with the specified name. +// Parameters: +// parameters - the name availability request parameters. +func (client ServersClient) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequest) (result CheckNameAvailabilityResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ServersClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServersClient) CheckNameAvailabilityPreparer(ctx context.Context, parameters CheckNameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServersClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested server resource state. +func (client ServersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (*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 = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", 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 ServersClient) CreateOrUpdateSender(req *http.Request) (future ServersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateOrUpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServersClient) DeletePreparer(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 = "2019-06-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}", 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 ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "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.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) 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 = "2019-06-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}", 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 ServersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ImportDatabase imports a bacpac into a new database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the database import request parameters. +func (client ServersClient) ImportDatabase(ctx context.Context, resourceGroupName string, serverName string, parameters ImportNewDatabaseDefinition) (result ServersImportDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ImportDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ServersClient", "ImportDatabase", err.Error()) + } + + req, err := client.ImportDatabasePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ImportDatabase", nil, "Failure preparing request") + return + } + + result, err = client.ImportDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ImportDatabase", result.Response(), "Failure sending request") + return + } + + return +} + +// ImportDatabasePreparer prepares the ImportDatabase request. +func (client ServersClient) ImportDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ImportNewDatabaseDefinition) (*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 = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImportDatabaseSender sends the ImportDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ImportDatabaseSender(req *http.Request) (future ServersImportDatabaseFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ImportDatabaseResponder handles the response to the ImportDatabase request. The method always +// closes the http.Response Body. +func (client ServersClient) ImportDatabaseResponder(resp *http.Response) (result ImportExportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all servers in the subscription. +func (client ServersClient) List(ctx context.Context) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServersClient) ListResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListComplete(ctx context.Context) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of servers in a resource groups. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested server resource state. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (result ServersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (*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 = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", 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 ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serversecurityalertpolicies.go b/services/preview/sql/mgmt/v3.0/sql/serversecurityalertpolicies.go new file mode 100644 index 000000000000..e024cf49175a --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serversecurityalertpolicies.go @@ -0,0 +1,315 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerSecurityAlertPoliciesClient 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 ServerSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewServerSecurityAlertPoliciesClient creates an instance of the ServerSecurityAlertPoliciesClient client. +func NewServerSecurityAlertPoliciesClient(subscriptionID string) ServerSecurityAlertPoliciesClient { + return NewServerSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerSecurityAlertPoliciesClientWithBaseURI creates an instance of the ServerSecurityAlertPoliciesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerSecurityAlertPoliciesClient { + return ServerSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a threat detection policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the server security alert policy. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (result ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "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.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", 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 ServerSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a server's security alert policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "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.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "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}/securityAlertPolicies/{securityAlertPolicyName}", 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 ServerSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer get the server's threat detection policies. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerSecurityAlertPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result LogicalServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.lssaplr.Response.Response != nil { + sc = result.lssaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.lssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.lssaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.lssaplr.hasNextLink() && result.lssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerSecurityAlertPoliciesClient) 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}/securityAlertPolicies", 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 ServerSecurityAlertPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) ListByServerResponder(resp *http.Response) (result LogicalServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerSecurityAlertPoliciesClient) listByServerNextResults(ctx context.Context, lastResults LogicalServerSecurityAlertPolicyListResult) (result LogicalServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.logicalServerSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "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.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerSecurityAlertPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result LogicalServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/servertrustgroups.go b/services/preview/sql/mgmt/v3.0/sql/servertrustgroups.go new file mode 100644 index 000000000000..ecb15a55b705 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/servertrustgroups.go @@ -0,0 +1,527 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerTrustGroupsClient 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 ServerTrustGroupsClient struct { + BaseClient +} + +// NewServerTrustGroupsClient creates an instance of the ServerTrustGroupsClient client. +func NewServerTrustGroupsClient(subscriptionID string) ServerTrustGroupsClient { + return NewServerTrustGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerTrustGroupsClientWithBaseURI creates an instance of the ServerTrustGroupsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServerTrustGroupsClientWithBaseURI(baseURI string, subscriptionID string) ServerTrustGroupsClient { + return ServerTrustGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// serverTrustGroupName - the name of the server trust group. +// parameters - the server trust group parameters. +func (client ServerTrustGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string, parameters ServerTrustGroup) (result ServerTrustGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerTrustGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerTrustGroupProperties.GroupMembers", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ServerTrustGroupProperties.TrustScopes", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ServerTrustGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, locationName, serverTrustGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerTrustGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string, parameters ServerTrustGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverTrustGroupName": autorest.Encode("path", serverTrustGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", 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 ServerTrustGroupsClient) CreateOrUpdateSender(req *http.Request) (future ServerTrustGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerTrustGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// serverTrustGroupName - the name of the server trust group. +func (client ServerTrustGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result ServerTrustGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, locationName, serverTrustGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerTrustGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverTrustGroupName": autorest.Encode("path", serverTrustGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", 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 ServerTrustGroupsClient) DeleteSender(req *http.Request) (future ServerTrustGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// serverTrustGroupName - the name of the server trust group. +func (client ServerTrustGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result ServerTrustGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, locationName, serverTrustGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "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.ServerTrustGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerTrustGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverTrustGroupName": autorest.Encode("path", serverTrustGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", 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 ServerTrustGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) GetResponder(resp *http.Response) (result ServerTrustGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a server trust groups by instance name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ServerTrustGroupsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ServerTrustGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByInstance") + defer func() { + sc := -1 + if result.stglr.Response.Response != nil { + sc = result.stglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.stglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.stglr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.stglr.hasNextLink() && result.stglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ServerTrustGroupsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/managedInstances/{managedInstanceName}/serverTrustGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) ListByInstanceResponder(resp *http.Response) (result ServerTrustGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ServerTrustGroupsClient) listByInstanceNextResults(ctx context.Context, lastResults ServerTrustGroupListResult) (result ServerTrustGroupListResult, err error) { + req, err := lastResults.serverTrustGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerTrustGroupsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ServerTrustGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// ListByLocation lists a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +func (client ServerTrustGroupsClient) ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result ServerTrustGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.stglr.Response.Response != nil { + sc = result.stglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, resourceGroupName, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.stglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.stglr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.stglr.hasNextLink() && result.stglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client ServerTrustGroupsClient) ListByLocationPreparer(ctx context.Context, resourceGroupName string, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02-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/locations/{locationName}/serverTrustGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) ListByLocationResponder(resp *http.Response) (result ServerTrustGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client ServerTrustGroupsClient) listByLocationNextResults(ctx context.Context, lastResults ServerTrustGroupListResult) (result ServerTrustGroupListResult, err error) { + req, err := lastResults.serverTrustGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerTrustGroupsClient) ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result ServerTrustGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serverusages.go b/services/preview/sql/mgmt/v3.0/sql/serverusages.go new file mode 100644 index 000000000000..662861e4c6cf --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serverusages.go @@ -0,0 +1,110 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerUsagesClient 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 ServerUsagesClient struct { + BaseClient +} + +// NewServerUsagesClient creates an instance of the ServerUsagesClient client. +func NewServerUsagesClient(subscriptionID string) ServerUsagesClient { + return NewServerUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerUsagesClientWithBaseURI creates an instance of the ServerUsagesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerUsagesClientWithBaseURI(baseURI string, subscriptionID string) ServerUsagesClient { + return ServerUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer returns server usages. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerUsagesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerUsageListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerUsagesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerUsagesClient) 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 = "2014-04-01" + 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}/usages", 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 ServerUsagesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerUsagesClient) ListByServerResponder(resp *http.Response) (result ServerUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/servervulnerabilityassessments.go b/services/preview/sql/mgmt/v3.0/sql/servervulnerabilityassessments.go new file mode 100644 index 000000000000..485a788ebf2e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/servervulnerabilityassessments.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerVulnerabilityAssessmentsClient 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 ServerVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewServerVulnerabilityAssessmentsClient creates an instance of the ServerVulnerabilityAssessmentsClient client. +func NewServerVulnerabilityAssessmentsClient(subscriptionID string) ServerVulnerabilityAssessmentsClient { + return NewServerVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerVulnerabilityAssessmentsClientWithBaseURI creates an instance of the ServerVulnerabilityAssessmentsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewServerVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ServerVulnerabilityAssessmentsClient { + return ServerVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's vulnerability assessment. +// Parameters: +// resourceGroupName - 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 - the name of the server for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerVulnerabilityAssessment) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerVulnerabilityAssessmentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerVulnerabilityAssessmentProperties.StorageContainerPath", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "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.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ServerVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the server's vulnerability assessment. +// Parameters: +// resourceGroupName - 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 - the name of the server for which the vulnerability assessment is defined. +func (client ServerVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerVulnerabilityAssessmentsClient) DeletePreparer(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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-06-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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ServerVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the server's vulnerability assessment. +// Parameters: +// resourceGroupName - 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 - the name of the server for which the vulnerability assessment is defined. +func (client ServerVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "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.ServerVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerVulnerabilityAssessmentsClient) 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), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2018-06-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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", 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 ServerVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the vulnerability assessment policies associated with a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerVulnerabilityAssessmentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.ListByServer") + defer func() { + sc := -1 + if result.svalr.Response.Response != nil { + sc = result.svalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.svalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.svalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.svalr.hasNextLink() && result.svalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerVulnerabilityAssessmentsClient) 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 = "2018-06-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}/vulnerabilityAssessments", 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 ServerVulnerabilityAssessmentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) ListByServerResponder(resp *http.Response) (result ServerVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerVulnerabilityAssessmentsClient) listByServerNextResults(ctx context.Context, lastResults ServerVulnerabilityAssessmentListResult) (result ServerVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.serverVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "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.ServerVulnerabilityAssessmentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerVulnerabilityAssessmentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/serviceobjectives.go b/services/preview/sql/mgmt/v3.0/sql/serviceobjectives.go new file mode 100644 index 000000000000..0b21dd5344f9 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/serviceobjectives.go @@ -0,0 +1,190 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServiceObjectivesClient 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 ServiceObjectivesClient struct { + BaseClient +} + +// NewServiceObjectivesClient creates an instance of the ServiceObjectivesClient client. +func NewServiceObjectivesClient(subscriptionID string) ServiceObjectivesClient { + return NewServiceObjectivesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceObjectivesClientWithBaseURI creates an instance of the ServiceObjectivesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceObjectivesClientWithBaseURI(baseURI string, subscriptionID string) ServiceObjectivesClient { + return ServiceObjectivesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database service objective. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// serviceObjectiveName - the name of the service objective to retrieve. +func (client ServiceObjectivesClient) Get(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (result ServiceObjective, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceObjectivesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, serviceObjectiveName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "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.ServiceObjectivesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceObjectivesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "serviceObjectiveName": autorest.Encode("path", serviceObjectiveName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/serviceObjectives/{serviceObjectiveName}", 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 ServiceObjectivesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) GetResponder(resp *http.Response) (result ServiceObjective, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns database service objectives. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServiceObjectivesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServiceObjectiveListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceObjectivesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServiceObjectivesClient) 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 = "2014-04-01" + 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}/serviceObjectives", 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 ServiceObjectivesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) ListByServerResponder(resp *http.Response) (result ServiceObjectiveListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/servicetieradvisors.go b/services/preview/sql/mgmt/v3.0/sql/servicetieradvisors.go new file mode 100644 index 000000000000..7886aa585995 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/servicetieradvisors.go @@ -0,0 +1,194 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServiceTierAdvisorsClient 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 ServiceTierAdvisorsClient struct { + BaseClient +} + +// NewServiceTierAdvisorsClient creates an instance of the ServiceTierAdvisorsClient client. +func NewServiceTierAdvisorsClient(subscriptionID string) ServiceTierAdvisorsClient { + return NewServiceTierAdvisorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceTierAdvisorsClientWithBaseURI creates an instance of the ServiceTierAdvisorsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceTierAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) ServiceTierAdvisorsClient { + return ServiceTierAdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a service tier advisor. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of database. +// serviceTierAdvisorName - the name of service tier advisor. +func (client ServiceTierAdvisorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (result ServiceTierAdvisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceTierAdvisorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, serviceTierAdvisorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "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.ServiceTierAdvisorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceTierAdvisorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "serviceTierAdvisorName": autorest.Encode("path", serviceTierAdvisorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + 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}/serviceTierAdvisors/{serviceTierAdvisorName}", 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 ServiceTierAdvisorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceTierAdvisorsClient) GetResponder(resp *http.Response) (result ServiceTierAdvisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns service tier advisors for specified database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of database. +func (client ServiceTierAdvisorsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ServiceTierAdvisorListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceTierAdvisorsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceTierAdvisorsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ServiceTierAdvisorsClient) ListByDatabasePreparer(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 = "2014-04-01" + 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}/serviceTierAdvisors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceTierAdvisorsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ServiceTierAdvisorsClient) ListByDatabaseResponder(resp *http.Response) (result ServiceTierAdvisorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/v3.0/sql/sqlapi/interfaces.go new file mode 100644 index 000000000000..3aea59e1830e --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/sqlapi/interfaces.go @@ -0,0 +1,1038 @@ +package sqlapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/azure-sdk-for-go/services/preview/sql/mgmt/v3.0/sql" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/gofrs/uuid" +) + +// RecoverableDatabasesClientAPI contains the set of methods on the RecoverableDatabasesClient type. +type RecoverableDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RecoverableDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RecoverableDatabaseListResult, err error) +} + +var _ RecoverableDatabasesClientAPI = (*sql.RecoverableDatabasesClient)(nil) + +// RestorableDroppedDatabasesClientAPI contains the set of methods on the RestorableDroppedDatabasesClient type. +type RestorableDroppedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppededDatabaseID string) (result sql.RestorableDroppedDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResult, err error) +} + +var _ RestorableDroppedDatabasesClientAPI = (*sql.RestorableDroppedDatabasesClient)(nil) + +// ServerConnectionPoliciesClientAPI contains the set of methods on the ServerConnectionPoliciesClient type. +type ServerConnectionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerConnectionPolicy) (result sql.ServerConnectionPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicy, err error) +} + +var _ ServerConnectionPoliciesClientAPI = (*sql.ServerConnectionPoliciesClient)(nil) + +// DatabaseThreatDetectionPoliciesClientAPI contains the set of methods on the DatabaseThreatDetectionPoliciesClient type. +type DatabaseThreatDetectionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseSecurityAlertPolicy) (result sql.DatabaseSecurityAlertPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseSecurityAlertPolicy, err error) +} + +var _ DatabaseThreatDetectionPoliciesClientAPI = (*sql.DatabaseThreatDetectionPoliciesClient)(nil) + +// DataMaskingPoliciesClientAPI contains the set of methods on the DataMaskingPoliciesClient type. +type DataMaskingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DataMaskingPolicy) (result sql.DataMaskingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataMaskingPolicy, err error) +} + +var _ DataMaskingPoliciesClientAPI = (*sql.DataMaskingPoliciesClient)(nil) + +// DataMaskingRulesClientAPI contains the set of methods on the DataMaskingRulesClient type. +type DataMaskingRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters sql.DataMaskingRule) (result sql.DataMaskingRule, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataMaskingRuleListResult, err error) +} + +var _ DataMaskingRulesClientAPI = (*sql.DataMaskingRulesClient)(nil) + +// FirewallRulesClientAPI contains the set of methods on the FirewallRulesClient type. +type FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters sql.FirewallRule) (result sql.FirewallRule, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result sql.FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.FirewallRuleListResult, err error) +} + +var _ FirewallRulesClientAPI = (*sql.FirewallRulesClient)(nil) + +// GeoBackupPoliciesClientAPI contains the set of methods on the GeoBackupPoliciesClient type. +type GeoBackupPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.GeoBackupPolicy) (result sql.GeoBackupPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.GeoBackupPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.GeoBackupPolicyListResult, err error) +} + +var _ GeoBackupPoliciesClientAPI = (*sql.GeoBackupPoliciesClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.Database) (result sql.DatabasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesDeleteFuture, err error) + Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExportDatabaseDefinition) (result sql.DatabasesExportFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, replicaType sql.ReplicaType) (result sql.DatabasesFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.Database, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResultPage, err error) + ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResultIterator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultIterator, err error) + ListInaccessibleByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultPage, err error) + ListInaccessibleByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultIterator, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.MetricDefinitionListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.MetricListResult, err error) + Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesPauseFuture, err error) + Rename(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ResourceMoveDefinition) (result autorest.Response, err error) + Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesResumeFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseUpdate) (result sql.DatabasesUpdateFuture, err error) + UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesUpgradeDataWarehouseFuture, err error) +} + +var _ DatabasesClientAPI = (*sql.DatabasesClient)(nil) + +// ElasticPoolsClientAPI contains the set of methods on the ElasticPoolsClient type. +type ElasticPoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPool) (result sql.ElasticPoolsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPool, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultIterator, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.MetricDefinitionListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result sql.MetricListResult, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPoolUpdate) (result sql.ElasticPoolsUpdateFuture, err error) +} + +var _ ElasticPoolsClientAPI = (*sql.ElasticPoolsClient)(nil) + +// RecommendedElasticPoolsClientAPI contains the set of methods on the RecommendedElasticPoolsClient type. +type RecommendedElasticPoolsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (result sql.RecommendedElasticPool, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RecommendedElasticPoolListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, recommendedElasticPoolName string) (result sql.RecommendedElasticPoolListMetricsResult, err error) +} + +var _ RecommendedElasticPoolsClientAPI = (*sql.RecommendedElasticPoolsClient)(nil) + +// ReplicationLinksClientAPI contains the set of methods on the ReplicationLinksClient type. +type ReplicationLinksClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverFuture, err error) + FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLink, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResult, err error) + Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters sql.UnlinkParameters) (result sql.ReplicationLinksUnlinkFuture, err error) +} + +var _ ReplicationLinksClientAPI = (*sql.ReplicationLinksClient)(nil) + +// ServerCommunicationLinksClientAPI contains the set of methods on the ServerCommunicationLinksClient type. +type ServerCommunicationLinksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters sql.ServerCommunicationLink) (result sql.ServerCommunicationLinksCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result sql.ServerCommunicationLink, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerCommunicationLinkListResult, err error) +} + +var _ ServerCommunicationLinksClientAPI = (*sql.ServerCommunicationLinksClient)(nil) + +// ServiceObjectivesClientAPI contains the set of methods on the ServiceObjectivesClient type. +type ServiceObjectivesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (result sql.ServiceObjective, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServiceObjectiveListResult, err error) +} + +var _ ServiceObjectivesClientAPI = (*sql.ServiceObjectivesClient)(nil) + +// ElasticPoolActivitiesClientAPI contains the set of methods on the ElasticPoolActivitiesClient type. +type ElasticPoolActivitiesClientAPI interface { + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolActivityListResult, err error) +} + +var _ ElasticPoolActivitiesClientAPI = (*sql.ElasticPoolActivitiesClient)(nil) + +// ElasticPoolDatabaseActivitiesClientAPI contains the set of methods on the ElasticPoolDatabaseActivitiesClient type. +type ElasticPoolDatabaseActivitiesClientAPI interface { + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolDatabaseActivityListResult, err error) +} + +var _ ElasticPoolDatabaseActivitiesClientAPI = (*sql.ElasticPoolDatabaseActivitiesClient)(nil) + +// ServiceTierAdvisorsClientAPI contains the set of methods on the ServiceTierAdvisorsClient type. +type ServiceTierAdvisorsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, serviceTierAdvisorName string) (result sql.ServiceTierAdvisor, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ServiceTierAdvisorListResult, err error) +} + +var _ ServiceTierAdvisorsClientAPI = (*sql.ServiceTierAdvisorsClient)(nil) + +// TransparentDataEncryptionsClientAPI contains the set of methods on the TransparentDataEncryptionsClient type. +type TransparentDataEncryptionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.TransparentDataEncryption) (result sql.TransparentDataEncryption, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryption, err error) +} + +var _ TransparentDataEncryptionsClientAPI = (*sql.TransparentDataEncryptionsClient)(nil) + +// TransparentDataEncryptionActivitiesClientAPI contains the set of methods on the TransparentDataEncryptionActivitiesClient type. +type TransparentDataEncryptionActivitiesClientAPI interface { + ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryptionActivityListResult, err error) +} + +var _ TransparentDataEncryptionActivitiesClientAPI = (*sql.TransparentDataEncryptionActivitiesClient)(nil) + +// ServerUsagesClientAPI contains the set of methods on the ServerUsagesClient type. +type ServerUsagesClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerUsageListResult, err error) +} + +var _ ServerUsagesClientAPI = (*sql.ServerUsagesClient)(nil) + +// DatabaseUsagesClientAPI contains the set of methods on the DatabaseUsagesClient type. +type DatabaseUsagesClientAPI interface { + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseUsageListResult, err error) +} + +var _ DatabaseUsagesClientAPI = (*sql.DatabaseUsagesClient)(nil) + +// DatabaseAutomaticTuningClientAPI contains the set of methods on the DatabaseAutomaticTuningClient type. +type DatabaseAutomaticTuningClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseAutomaticTuning, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseAutomaticTuning) (result sql.DatabaseAutomaticTuning, err error) +} + +var _ DatabaseAutomaticTuningClientAPI = (*sql.DatabaseAutomaticTuningClient)(nil) + +// EncryptionProtectorsClientAPI contains the set of methods on the EncryptionProtectorsClient type. +type EncryptionProtectorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.EncryptionProtector) (result sql.EncryptionProtectorsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtector, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorListResultIterator, err error) + Revalidate(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorsRevalidateFuture, err error) +} + +var _ EncryptionProtectorsClientAPI = (*sql.EncryptionProtectorsClient)(nil) + +// FailoverGroupsClientAPI contains the set of methods on the FailoverGroupsClient type. +type FailoverGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters sql.FailoverGroup) (result sql.FailoverGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsFailoverFuture, err error) + ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsForceFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroup, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.FailoverGroupListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.FailoverGroupListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters sql.FailoverGroupUpdate) (result sql.FailoverGroupsUpdateFuture, err error) +} + +var _ FailoverGroupsClientAPI = (*sql.FailoverGroupsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result sql.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result sql.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*sql.OperationsClient)(nil) + +// ServerKeysClientAPI contains the set of methods on the ServerKeysClient type. +type ServerKeysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters sql.ServerKey) (result sql.ServerKeysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result sql.ServerKeysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result sql.ServerKey, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerKeyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerKeyListResultIterator, err error) +} + +var _ ServerKeysClientAPI = (*sql.ServerKeysClient)(nil) + +// SyncAgentsClientAPI contains the set of methods on the SyncAgentsClient type. +type SyncAgentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters sql.SyncAgent) (result sql.SyncAgentsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentsDeleteFuture, err error) + GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentKeyProperties, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgent, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.SyncAgentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.SyncAgentListResultIterator, err error) + ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentLinkedDatabaseListResultPage, err error) + ListLinkedDatabasesComplete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentLinkedDatabaseListResultIterator, err error) +} + +var _ SyncAgentsClientAPI = (*sql.SyncAgentsClient)(nil) + +// SubscriptionUsagesClientAPI contains the set of methods on the SubscriptionUsagesClient type. +type SubscriptionUsagesClientAPI interface { + Get(ctx context.Context, locationName string, usageName string) (result sql.SubscriptionUsage, err error) + ListByLocation(ctx context.Context, locationName string) (result sql.SubscriptionUsageListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string) (result sql.SubscriptionUsageListResultIterator, err error) +} + +var _ SubscriptionUsagesClientAPI = (*sql.SubscriptionUsagesClient)(nil) + +// VirtualClustersClientAPI contains the set of methods on the VirtualClustersClient type. +type VirtualClustersClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.VirtualClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.VirtualCluster, err error) + List(ctx context.Context) (result sql.VirtualClusterListResultPage, err error) + ListComplete(ctx context.Context) (result sql.VirtualClusterListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.VirtualClusterListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.VirtualClusterListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters sql.VirtualClusterUpdate) (result sql.VirtualClustersUpdateFuture, err error) +} + +var _ VirtualClustersClientAPI = (*sql.VirtualClustersClient)(nil) + +// VirtualNetworkRulesClientAPI contains the set of methods on the VirtualNetworkRulesClient type. +type VirtualNetworkRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters sql.VirtualNetworkRule) (result sql.VirtualNetworkRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result sql.VirtualNetworkRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result sql.VirtualNetworkRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.VirtualNetworkRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.VirtualNetworkRuleListResultIterator, err error) +} + +var _ VirtualNetworkRulesClientAPI = (*sql.VirtualNetworkRulesClient)(nil) + +// ExtendedDatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedDatabaseBlobAuditingPoliciesClient type. +type ExtendedDatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExtendedDatabaseBlobAuditingPolicy) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ ExtendedDatabaseBlobAuditingPoliciesClientAPI = (*sql.ExtendedDatabaseBlobAuditingPoliciesClient)(nil) + +// ExtendedServerBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedServerBlobAuditingPoliciesClient type. +type ExtendedServerBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ExtendedServerBlobAuditingPolicy) (result sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultIterator, err error) +} + +var _ ExtendedServerBlobAuditingPoliciesClientAPI = (*sql.ExtendedServerBlobAuditingPoliciesClient)(nil) + +// ServerBlobAuditingPoliciesClientAPI contains the set of methods on the ServerBlobAuditingPoliciesClient type. +type ServerBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerBlobAuditingPolicy) (result sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultIterator, err error) +} + +var _ ServerBlobAuditingPoliciesClientAPI = (*sql.ServerBlobAuditingPoliciesClient)(nil) + +// DatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the DatabaseBlobAuditingPoliciesClient type. +type DatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseBlobAuditingPolicy) (result sql.DatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ DatabaseBlobAuditingPoliciesClientAPI = (*sql.DatabaseBlobAuditingPoliciesClient)(nil) + +// DatabaseVulnerabilityAssessmentRuleBaselinesClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentRuleBaselinesClient type. +type DatabaseVulnerabilityAssessmentRuleBaselinesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName, parameters sql.DatabaseVulnerabilityAssessmentRuleBaseline) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) +} + +var _ DatabaseVulnerabilityAssessmentRuleBaselinesClientAPI = (*sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient)(nil) + +// DatabaseVulnerabilityAssessmentsClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentsClient type. +type DatabaseVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseVulnerabilityAssessment) (result sql.DatabaseVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseVulnerabilityAssessment, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultIterator, err error) +} + +var _ DatabaseVulnerabilityAssessmentsClientAPI = (*sql.DatabaseVulnerabilityAssessmentsClient)(nil) + +// JobAgentsClientAPI contains the set of methods on the JobAgentsClient type. +type JobAgentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters sql.JobAgent) (result sql.JobAgentsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobAgentsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobAgent, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.JobAgentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.JobAgentListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters sql.JobAgentUpdate) (result sql.JobAgentsUpdateFuture, err error) +} + +var _ JobAgentsClientAPI = (*sql.JobAgentsClient)(nil) + +// JobCredentialsClientAPI contains the set of methods on the JobCredentialsClient type. +type JobCredentialsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string, parameters sql.JobCredential) (result sql.JobCredential, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result sql.JobCredential, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobCredentialListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobCredentialListResultIterator, err error) +} + +var _ JobCredentialsClientAPI = (*sql.JobCredentialsClient)(nil) + +// JobExecutionsClientAPI contains the set of methods on the JobExecutionsClient type. +type JobExecutionsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result autorest.Response, err error) + Create(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobExecutionsCreateFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result sql.JobExecutionsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result sql.JobExecution, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) + ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) +} + +var _ JobExecutionsClientAPI = (*sql.JobExecutionsClient)(nil) + +// JobsClientAPI contains the set of methods on the JobsClient type. +type JobsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, parameters sql.Job) (result sql.Job, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.Job, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobListResultIterator, err error) +} + +var _ JobsClientAPI = (*sql.JobsClient)(nil) + +// JobStepExecutionsClientAPI contains the set of methods on the JobStepExecutionsClient type. +type JobStepExecutionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (result sql.JobExecution, err error) + ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) +} + +var _ JobStepExecutionsClientAPI = (*sql.JobStepExecutionsClient)(nil) + +// JobStepsClientAPI contains the set of methods on the JobStepsClient type. +type JobStepsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string, parameters sql.JobStep) (result sql.JobStep, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result sql.JobStep, err error) + GetByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32, stepName string) (result sql.JobStep, err error) + ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobStepListResultPage, err error) + ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobStepListResultIterator, err error) + ListByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result sql.JobStepListResultPage, err error) + ListByVersionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result sql.JobStepListResultIterator, err error) +} + +var _ JobStepsClientAPI = (*sql.JobStepsClient)(nil) + +// JobTargetExecutionsClientAPI contains the set of methods on the JobTargetExecutionsClient type. +type JobTargetExecutionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, targetID uuid.UUID) (result sql.JobExecution, err error) + ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) + ListByStep(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByStepComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) +} + +var _ JobTargetExecutionsClientAPI = (*sql.JobTargetExecutionsClient)(nil) + +// JobTargetGroupsClientAPI contains the set of methods on the JobTargetGroupsClient type. +type JobTargetGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string, parameters sql.JobTargetGroup) (result sql.JobTargetGroup, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result sql.JobTargetGroup, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobTargetGroupListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobTargetGroupListResultIterator, err error) +} + +var _ JobTargetGroupsClientAPI = (*sql.JobTargetGroupsClient)(nil) + +// JobVersionsClientAPI contains the set of methods on the JobVersionsClient type. +type JobVersionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result sql.JobVersion, err error) + ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobVersionListResultPage, err error) + ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobVersionListResultIterator, err error) +} + +var _ JobVersionsClientAPI = (*sql.JobVersionsClient)(nil) + +// LongTermRetentionBackupsClientAPI contains the set of methods on the LongTermRetentionBackupsClient type. +type LongTermRetentionBackupsClientAPI interface { + Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) +} + +var _ LongTermRetentionBackupsClientAPI = (*sql.LongTermRetentionBackupsClient)(nil) + +// BackupLongTermRetentionPoliciesClientAPI contains the set of methods on the BackupLongTermRetentionPoliciesClient type. +type BackupLongTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupLongTermRetentionPolicy) (result sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupLongTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupLongTermRetentionPolicy, err error) +} + +var _ BackupLongTermRetentionPoliciesClientAPI = (*sql.BackupLongTermRetentionPoliciesClient)(nil) + +// ManagedBackupShortTermRetentionPoliciesClientAPI contains the set of methods on the ManagedBackupShortTermRetentionPoliciesClient type. +type ManagedBackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedBackupShortTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedBackupShortTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedBackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ ManagedBackupShortTermRetentionPoliciesClientAPI = (*sql.ManagedBackupShortTermRetentionPoliciesClient)(nil) + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientAPI contains the set of methods on the ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient type. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.ManagedBackupShortTermRetentionPolicy, err error) + ListByRestorableDroppedDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.ManagedBackupShortTermRetentionPolicyListResultPage, err error) + ListByRestorableDroppedDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.ManagedBackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientAPI = (*sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient)(nil) + +// ServerAutomaticTuningClientAPI contains the set of methods on the ServerAutomaticTuningClient type. +type ServerAutomaticTuningClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAutomaticTuning, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAutomaticTuning) (result sql.ServerAutomaticTuning, err error) +} + +var _ ServerAutomaticTuningClientAPI = (*sql.ServerAutomaticTuningClient)(nil) + +// ServerDNSAliasesClientAPI contains the set of methods on the ServerDNSAliasesClient type. +type ServerDNSAliasesClientAPI interface { + Acquire(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string, parameters sql.ServerDNSAliasAcquisition) (result sql.ServerDNSAliasesAcquireFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result sql.ServerDNSAliasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result sql.ServerDNSAliasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result sql.ServerDNSAlias, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerDNSAliasListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerDNSAliasListResultIterator, err error) +} + +var _ ServerDNSAliasesClientAPI = (*sql.ServerDNSAliasesClient)(nil) + +// ServerSecurityAlertPoliciesClientAPI contains the set of methods on the ServerSecurityAlertPoliciesClient type. +type ServerSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerSecurityAlertPolicy) (result sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerSecurityAlertPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.LogicalServerSecurityAlertPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.LogicalServerSecurityAlertPolicyListResultIterator, err error) +} + +var _ ServerSecurityAlertPoliciesClientAPI = (*sql.ServerSecurityAlertPoliciesClient)(nil) + +// RestorableDroppedManagedDatabasesClientAPI contains the set of methods on the RestorableDroppedManagedDatabasesClient type. +type RestorableDroppedManagedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultIterator, err error) +} + +var _ RestorableDroppedManagedDatabasesClientAPI = (*sql.RestorableDroppedManagedDatabasesClient)(nil) + +// RestorePointsClientAPI contains the set of methods on the RestorePointsClient type. +type RestorePointsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.CreateDatabaseRestorePointDefinition) (result sql.RestorePointsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result sql.RestorePoint, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RestorePointListResult, err error) +} + +var _ RestorePointsClientAPI = (*sql.RestorePointsClient)(nil) + +// ManagedDatabaseSecurityAlertPoliciesClientAPI contains the set of methods on the ManagedDatabaseSecurityAlertPoliciesClient type. +type ManagedDatabaseSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedDatabaseSecurityAlertPolicy) (result sql.ManagedDatabaseSecurityAlertPolicy, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseSecurityAlertPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseSecurityAlertPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseSecurityAlertPolicyListResultIterator, err error) +} + +var _ ManagedDatabaseSecurityAlertPoliciesClientAPI = (*sql.ManagedDatabaseSecurityAlertPoliciesClient)(nil) + +// ManagedServerSecurityAlertPoliciesClientAPI contains the set of methods on the ManagedServerSecurityAlertPoliciesClient type. +type ManagedServerSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedServerSecurityAlertPolicy) (result sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerSecurityAlertPolicy, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerSecurityAlertPolicyListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerSecurityAlertPolicyListResultIterator, err error) +} + +var _ ManagedServerSecurityAlertPoliciesClientAPI = (*sql.ManagedServerSecurityAlertPoliciesClient)(nil) + +// SensitivityLabelsClientAPI contains the set of methods on the SensitivityLabelsClient type. +type SensitivityLabelsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + DisableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + EnableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) + ListCurrentByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.SensitivityLabelListResultIterator, err error) + ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result sql.SensitivityLabelListResultIterator, err error) +} + +var _ SensitivityLabelsClientAPI = (*sql.SensitivityLabelsClient)(nil) + +// ManagedInstanceAdministratorsClientAPI contains the set of methods on the ManagedInstanceAdministratorsClient type. +type ManagedInstanceAdministratorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceAdministrator) (result sql.ManagedInstanceAdministratorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministratorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministrator, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministratorListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministratorListResultIterator, err error) +} + +var _ ManagedInstanceAdministratorsClientAPI = (*sql.ManagedInstanceAdministratorsClient)(nil) + +// DatabaseOperationsClientAPI contains the set of methods on the DatabaseOperationsClient type. +type DatabaseOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseOperationListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseOperationListResultIterator, err error) +} + +var _ DatabaseOperationsClientAPI = (*sql.DatabaseOperationsClient)(nil) + +// ElasticPoolOperationsClientAPI contains the set of methods on the ElasticPoolOperationsClient type. +type ElasticPoolOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolOperationListResultPage, err error) + ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolOperationListResultIterator, err error) +} + +var _ ElasticPoolOperationsClientAPI = (*sql.ElasticPoolOperationsClient)(nil) + +// DatabaseVulnerabilityAssessmentScansClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentScansClient type. +type DatabaseVulnerabilityAssessmentScansClientAPI interface { + Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansExport, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.VulnerabilityAssessmentScanRecord, err error) + InitiateScan(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultIterator, err error) +} + +var _ DatabaseVulnerabilityAssessmentScansClientAPI = (*sql.DatabaseVulnerabilityAssessmentScansClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient type. +type ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName, parameters sql.DatabaseVulnerabilityAssessmentRuleBaseline) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentScansClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentScansClient type. +type ManagedDatabaseVulnerabilityAssessmentScansClientAPI interface { + Export(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansExport, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.VulnerabilityAssessmentScanRecord, err error) + InitiateScan(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultIterator, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentScansClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentScansClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentsClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentsClient type. +type ManagedDatabaseVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.DatabaseVulnerabilityAssessment) (result sql.DatabaseVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessment, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentsClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentsClient)(nil) + +// InstanceFailoverGroupsClientAPI contains the set of methods on the InstanceFailoverGroupsClient type. +type InstanceFailoverGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters sql.InstanceFailoverGroup) (result sql.InstanceFailoverGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsFailoverFuture, err error) + ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroup, err error) + ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result sql.InstanceFailoverGroupListResultPage, err error) + ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result sql.InstanceFailoverGroupListResultIterator, err error) +} + +var _ InstanceFailoverGroupsClientAPI = (*sql.InstanceFailoverGroupsClient)(nil) + +// TdeCertificatesClientAPI contains the set of methods on the TdeCertificatesClient type. +type TdeCertificatesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, parameters sql.TdeCertificate) (result sql.TdeCertificatesCreateFuture, err error) +} + +var _ TdeCertificatesClientAPI = (*sql.TdeCertificatesClient)(nil) + +// ManagedInstanceTdeCertificatesClientAPI contains the set of methods on the ManagedInstanceTdeCertificatesClient type. +type ManagedInstanceTdeCertificatesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.TdeCertificate) (result sql.ManagedInstanceTdeCertificatesCreateFuture, err error) +} + +var _ ManagedInstanceTdeCertificatesClientAPI = (*sql.ManagedInstanceTdeCertificatesClient)(nil) + +// ManagedInstanceKeysClientAPI contains the set of methods on the ManagedInstanceKeysClient type. +type ManagedInstanceKeysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters sql.ManagedInstanceKey) (result sql.ManagedInstanceKeysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result sql.ManagedInstanceKeysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result sql.ManagedInstanceKey, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result sql.ManagedInstanceKeyListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result sql.ManagedInstanceKeyListResultIterator, err error) +} + +var _ ManagedInstanceKeysClientAPI = (*sql.ManagedInstanceKeysClient)(nil) + +// ManagedInstanceEncryptionProtectorsClientAPI contains the set of methods on the ManagedInstanceEncryptionProtectorsClient type. +type ManagedInstanceEncryptionProtectorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceEncryptionProtector) (result sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtector, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorListResultIterator, err error) + Revalidate(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) +} + +var _ ManagedInstanceEncryptionProtectorsClientAPI = (*sql.ManagedInstanceEncryptionProtectorsClient)(nil) + +// RecoverableManagedDatabasesClientAPI contains the set of methods on the RecoverableManagedDatabasesClient type. +type RecoverableManagedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (result sql.RecoverableManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RecoverableManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RecoverableManagedDatabaseListResultIterator, err error) +} + +var _ RecoverableManagedDatabasesClientAPI = (*sql.RecoverableManagedDatabasesClient)(nil) + +// BackupShortTermRetentionPoliciesClientAPI contains the set of methods on the BackupShortTermRetentionPoliciesClient type. +type BackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ BackupShortTermRetentionPoliciesClientAPI = (*sql.BackupShortTermRetentionPoliciesClient)(nil) + +// ManagedInstanceVulnerabilityAssessmentsClientAPI contains the set of methods on the ManagedInstanceVulnerabilityAssessmentsClient type. +type ManagedInstanceVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceVulnerabilityAssessment) (result sql.ManagedInstanceVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceVulnerabilityAssessment, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceVulnerabilityAssessmentListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ManagedInstanceVulnerabilityAssessmentsClientAPI = (*sql.ManagedInstanceVulnerabilityAssessmentsClient)(nil) + +// ServerVulnerabilityAssessmentsClientAPI contains the set of methods on the ServerVulnerabilityAssessmentsClient type. +type ServerVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerVulnerabilityAssessment) (result sql.ServerVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerVulnerabilityAssessment, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerVulnerabilityAssessmentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ServerVulnerabilityAssessmentsClientAPI = (*sql.ServerVulnerabilityAssessmentsClient)(nil) + +// ManagedDatabaseSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseSensitivityLabelsClient type. +type ManagedDatabaseSensitivityLabelsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + DisableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + EnableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) + ListCurrentByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result sql.SensitivityLabelListResultIterator, err error) + ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, includeDisabledRecommendations *bool, skipToken string, filter string) (result sql.SensitivityLabelListResultIterator, err error) +} + +var _ ManagedDatabaseSensitivityLabelsClientAPI = (*sql.ManagedDatabaseSensitivityLabelsClient)(nil) + +// InstancePoolsClientAPI contains the set of methods on the InstancePoolsClient type. +type InstancePoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, instancePoolName string, parameters sql.InstancePool) (result sql.InstancePoolsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, instancePoolName string) (result sql.InstancePoolsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, instancePoolName string) (result sql.InstancePool, err error) + List(ctx context.Context) (result sql.InstancePoolListResultPage, err error) + ListComplete(ctx context.Context) (result sql.InstancePoolListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.InstancePoolListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.InstancePoolListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, instancePoolName string, parameters sql.InstancePoolUpdate) (result sql.InstancePoolsUpdateFuture, err error) +} + +var _ InstancePoolsClientAPI = (*sql.InstancePoolsClient)(nil) + +// UsagesClientAPI contains the set of methods on the UsagesClient type. +type UsagesClientAPI interface { + ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result sql.UsageListResultPage, err error) + ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result sql.UsageListResultIterator, err error) +} + +var _ UsagesClientAPI = (*sql.UsagesClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, groupName string) (result sql.PrivateLinkResource, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateLinkResourceListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateLinkResourceListResultIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*sql.PrivateLinkResourcesClient)(nil) + +// ServersClientAPI contains the set of methods on the ServersClient type. +type ServersClientAPI interface { + CheckNameAvailability(ctx context.Context, parameters sql.CheckNameAvailabilityRequest) (result sql.CheckNameAvailabilityResponse, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.Server) (result sql.ServersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.Server, err error) + ImportDatabase(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ImportNewDatabaseDefinition) (result sql.ServersImportDatabaseFuture, err error) + List(ctx context.Context) (result sql.ServerListResultPage, err error) + ListComplete(ctx context.Context) (result sql.ServerListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.ServerListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.ServerListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerUpdate) (result sql.ServersUpdateFuture, err error) +} + +var _ ServersClientAPI = (*sql.ServersClient)(nil) + +// CapabilitiesClientAPI contains the set of methods on the CapabilitiesClient type. +type CapabilitiesClientAPI interface { + ListByLocation(ctx context.Context, locationName string, include sql.CapabilityGroup) (result sql.LocationCapabilities, err error) +} + +var _ CapabilitiesClientAPI = (*sql.CapabilitiesClient)(nil) + +// LongTermRetentionManagedInstanceBackupsClientAPI contains the set of methods on the LongTermRetentionManagedInstanceBackupsClient type. +type LongTermRetentionManagedInstanceBackupsClientAPI interface { + Delete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState1) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState1) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState2) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState2) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState3) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState3) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState4) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState4) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState5) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState5) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState6) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState6) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) +} + +var _ LongTermRetentionManagedInstanceBackupsClientAPI = (*sql.LongTermRetentionManagedInstanceBackupsClient)(nil) + +// ManagedInstanceLongTermRetentionPoliciesClientAPI contains the set of methods on the ManagedInstanceLongTermRetentionPoliciesClient type. +type ManagedInstanceLongTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedInstanceLongTermRetentionPolicy) (result sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedInstanceLongTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedInstanceLongTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedInstanceLongTermRetentionPolicyListResultIterator, err error) +} + +var _ ManagedInstanceLongTermRetentionPoliciesClientAPI = (*sql.ManagedInstanceLongTermRetentionPoliciesClient)(nil) + +// WorkloadGroupsClientAPI contains the set of methods on the WorkloadGroupsClient type. +type WorkloadGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, parameters sql.WorkloadGroup) (result sql.WorkloadGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadGroup, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.WorkloadGroupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.WorkloadGroupListResultIterator, err error) +} + +var _ WorkloadGroupsClientAPI = (*sql.WorkloadGroupsClient)(nil) + +// WorkloadClassifiersClientAPI contains the set of methods on the WorkloadClassifiersClient type. +type WorkloadClassifiersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string, parameters sql.WorkloadClassifier) (result sql.WorkloadClassifiersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result sql.WorkloadClassifiersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result sql.WorkloadClassifier, err error) + ListByWorkloadGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadClassifierListResultPage, err error) + ListByWorkloadGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadClassifierListResultIterator, err error) +} + +var _ WorkloadClassifiersClientAPI = (*sql.WorkloadClassifiersClient)(nil) + +// ManagedInstanceOperationsClientAPI contains the set of methods on the ManagedInstanceOperationsClient type. +type ManagedInstanceOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result sql.ManagedInstanceOperation, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceOperationListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceOperationListResultIterator, err error) +} + +var _ ManagedInstanceOperationsClientAPI = (*sql.ManagedInstanceOperationsClient)(nil) + +// ServerAzureADAdministratorsClientAPI contains the set of methods on the ServerAzureADAdministratorsClient type. +type ServerAzureADAdministratorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAzureADAdministrator) (result sql.ServerAzureADAdministratorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADAdministratorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADAdministrator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.AdministratorListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.AdministratorListResultIterator, err error) +} + +var _ ServerAzureADAdministratorsClientAPI = (*sql.ServerAzureADAdministratorsClient)(nil) + +// SyncGroupsClientAPI contains the set of methods on the SyncGroupsClient type. +type SyncGroupsClientAPI interface { + CancelSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters sql.SyncGroup) (result sql.SyncGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroup, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultIterator, err error) + ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) + ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) + ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultPage, err error) + ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultIterator, err error) + ListSyncDatabaseIds(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultPage, err error) + ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultIterator, err error) + RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsRefreshHubSchemaFuture, err error) + TriggerSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters sql.SyncGroup) (result sql.SyncGroupsUpdateFuture, err error) +} + +var _ SyncGroupsClientAPI = (*sql.SyncGroupsClient)(nil) + +// SyncMembersClientAPI contains the set of methods on the SyncMembersClient type. +type SyncMembersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters sql.SyncMember) (result sql.SyncMembersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMembersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMember, err error) + ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncMemberListResultPage, err error) + ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncMemberListResultIterator, err error) + ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) + ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) + RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMembersRefreshMemberSchemaFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters sql.SyncMember) (result sql.SyncMembersUpdateFuture, err error) +} + +var _ SyncMembersClientAPI = (*sql.SyncMembersClient)(nil) + +// ImportExportClientAPI contains the set of methods on the ImportExportClient type. +type ImportExportClientAPI interface { + Import(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ImportExistingDatabaseDefinition) (result sql.ImportExportImportFuture, err error) +} + +var _ ImportExportClientAPI = (*sql.ImportExportClient)(nil) + +// ManagedDatabasesClientAPI contains the set of methods on the ManagedDatabasesClient type. +type ManagedDatabasesClientAPI interface { + CompleteRestore(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.CompleteDatabaseRestoreDefinition) (result sql.ManagedDatabasesCompleteRestoreFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedDatabase) (result sql.ManagedDatabasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultIterator, err error) + ListInaccessibleByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultPage, err error) + ListInaccessibleByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedDatabaseUpdate) (result sql.ManagedDatabasesUpdateFuture, err error) +} + +var _ ManagedDatabasesClientAPI = (*sql.ManagedDatabasesClient)(nil) + +// ServerAzureADOnlyAuthenticationsClientAPI contains the set of methods on the ServerAzureADOnlyAuthenticationsClient type. +type ServerAzureADOnlyAuthenticationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAzureADOnlyAuthentication) (result sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADOnlyAuthenticationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADOnlyAuthentication, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.AzureADOnlyAuthListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.AzureADOnlyAuthListResultIterator, err error) +} + +var _ ServerAzureADOnlyAuthenticationsClientAPI = (*sql.ServerAzureADOnlyAuthenticationsClient)(nil) + +// ManagedInstancesClientAPI contains the set of methods on the ManagedInstancesClient type. +type ManagedInstancesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstance) (result sql.ManagedInstancesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancesDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType sql.ReplicaType) (result sql.ManagedInstancesFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstance, err error) + List(ctx context.Context) (result sql.ManagedInstanceListResultPage, err error) + ListComplete(ctx context.Context) (result sql.ManagedInstanceListResultIterator, err error) + ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string) (result sql.ManagedInstanceListResultPage, err error) + ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string) (result sql.ManagedInstanceListResultIterator, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.ManagedInstanceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.ManagedInstanceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceUpdate) (result sql.ManagedInstancesUpdateFuture, err error) +} + +var _ ManagedInstancesClientAPI = (*sql.ManagedInstancesClient)(nil) + +// ManagedInstanceAzureADOnlyAuthenticationsClientAPI contains the set of methods on the ManagedInstanceAzureADOnlyAuthenticationsClient type. +type ManagedInstanceAzureADOnlyAuthenticationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceAzureADOnlyAuthentication) (result sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthentication, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthListResultIterator, err error) +} + +var _ ManagedInstanceAzureADOnlyAuthenticationsClientAPI = (*sql.ManagedInstanceAzureADOnlyAuthenticationsClient)(nil) + +// ServerTrustGroupsClientAPI contains the set of methods on the ServerTrustGroupsClient type. +type ServerTrustGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string, parameters sql.ServerTrustGroup) (result sql.ServerTrustGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result sql.ServerTrustGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result sql.ServerTrustGroup, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ServerTrustGroupListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ServerTrustGroupListResultIterator, err error) + ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result sql.ServerTrustGroupListResultPage, err error) + ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result sql.ServerTrustGroupListResultIterator, err error) +} + +var _ ServerTrustGroupsClientAPI = (*sql.ServerTrustGroupsClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters sql.PrivateEndpointConnection) (result sql.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnection, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*sql.PrivateEndpointConnectionsClient)(nil) diff --git a/services/preview/sql/mgmt/v3.0/sql/subscriptionusages.go b/services/preview/sql/mgmt/v3.0/sql/subscriptionusages.go new file mode 100644 index 000000000000..2362a090b572 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/subscriptionusages.go @@ -0,0 +1,226 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SubscriptionUsagesClient 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 SubscriptionUsagesClient struct { + BaseClient +} + +// NewSubscriptionUsagesClient creates an instance of the SubscriptionUsagesClient client. +func NewSubscriptionUsagesClient(subscriptionID string) SubscriptionUsagesClient { + return NewSubscriptionUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionUsagesClientWithBaseURI creates an instance of the SubscriptionUsagesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSubscriptionUsagesClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionUsagesClient { + return SubscriptionUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a subscription usage metric. +// Parameters: +// locationName - the name of the region where the resource is located. +// usageName - name of usage metric to return. +func (client SubscriptionUsagesClient) Get(ctx context.Context, locationName string, usageName string) (result SubscriptionUsage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, usageName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "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.SubscriptionUsagesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubscriptionUsagesClient) GetPreparer(ctx context.Context, locationName string, usageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "usageName": autorest.Encode("path", usageName), + } + + 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}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}", 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 SubscriptionUsagesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) GetResponder(resp *http.Response) (result SubscriptionUsage, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation gets all subscription usage metrics in a given location. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client SubscriptionUsagesClient) ListByLocation(ctx context.Context, locationName string) (result SubscriptionUsageListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.ListByLocation") + defer func() { + sc := -1 + if result.sulr.Response.Response != nil { + sc = result.sulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.sulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.sulr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.sulr.hasNextLink() && result.sulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client SubscriptionUsagesClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "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}/providers/Microsoft.Sql/locations/{locationName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionUsagesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) ListByLocationResponder(resp *http.Response) (result SubscriptionUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client SubscriptionUsagesClient) listByLocationNextResults(ctx context.Context, lastResults SubscriptionUsageListResult) (result SubscriptionUsageListResult, err error) { + req, err := lastResults.subscriptionUsageListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionUsagesClient) ListByLocationComplete(ctx context.Context, locationName string) (result SubscriptionUsageListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/syncagents.go b/services/preview/sql/mgmt/v3.0/sql/syncagents.go new file mode 100644 index 000000000000..9ad3b1b33350 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/syncagents.go @@ -0,0 +1,597 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SyncAgentsClient 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 SyncAgentsClient struct { + BaseClient +} + +// NewSyncAgentsClient creates an instance of the SyncAgentsClient client. +func NewSyncAgentsClient(subscriptionID string) SyncAgentsClient { + return NewSyncAgentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncAgentsClientWithBaseURI creates an instance of the SyncAgentsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncAgentsClientWithBaseURI(baseURI string, subscriptionID string) SyncAgentsClient { + return SyncAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +// parameters - the requested sync agent resource state. +func (client SyncAgentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters SyncAgent) (result SyncAgentsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, syncAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SyncAgentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters SyncAgent) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", 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 SyncAgentsClient) CreateOrUpdateSender(req *http.Request) (future SyncAgentsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncAgentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2015-05-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}/syncAgents/{syncAgentName}", 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 SyncAgentsClient) DeleteSender(req *http.Request) (future SyncAgentsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateKey generates a sync agent key. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentKeyProperties, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.GenerateKey") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateKeyPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", resp, "Failure sending request") + return + } + + result, err = client.GenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", resp, "Failure responding to request") + return + } + + return +} + +// GenerateKeyPreparer prepares the GenerateKey request. +func (client SyncAgentsClient) GenerateKeyPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2015-05-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}/syncAgents/{syncAgentName}/generateKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateKeySender sends the GenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) GenerateKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateKeyResponder handles the response to the GenerateKey request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GenerateKeyResponder(resp *http.Response) (result SyncAgentKeyProperties, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "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.SyncAgentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncAgentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + 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}/syncAgents/{syncAgentName}", 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 SyncAgentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GetResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists sync agents in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +func (client SyncAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.salr.Response.Response != nil { + sc = result.salr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.salr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.salr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.salr.hasNextLink() && result.salr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client SyncAgentsClient) 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 = "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}/syncAgents", 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 SyncAgentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListByServerResponder(resp *http.Response) (result SyncAgentListResult, err error) { + err = autorest.Respond( + resp, + 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 SyncAgentsClient) listByServerNextResults(ctx context.Context, lastResults SyncAgentListResult) (result SyncAgentListResult, err error) { + req, err := lastResults.syncAgentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "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.SyncAgentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncAgentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// ListLinkedDatabases lists databases linked to a sync agent. +// Parameters: +// resourceGroupName - 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 - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListLinkedDatabases") + defer func() { + sc := -1 + if result.saldlr.Response.Response != nil { + sc = result.saldlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listLinkedDatabasesNextResults + req, err := client.ListLinkedDatabasesPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListLinkedDatabasesSender(req) + if err != nil { + result.saldlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", resp, "Failure sending request") + return + } + + result.saldlr, err = client.ListLinkedDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", resp, "Failure responding to request") + return + } + if result.saldlr.hasNextLink() && result.saldlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListLinkedDatabasesPreparer prepares the ListLinkedDatabases request. +func (client SyncAgentsClient) ListLinkedDatabasesPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + 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}/syncAgents/{syncAgentName}/linkedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLinkedDatabasesSender sends the ListLinkedDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) ListLinkedDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListLinkedDatabasesResponder handles the response to the ListLinkedDatabases request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListLinkedDatabasesResponder(resp *http.Response) (result SyncAgentLinkedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listLinkedDatabasesNextResults retrieves the next set of results, if any. +func (client SyncAgentsClient) listLinkedDatabasesNextResults(ctx context.Context, lastResults SyncAgentLinkedDatabaseListResult) (result SyncAgentLinkedDatabaseListResult, err error) { + req, err := lastResults.syncAgentLinkedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListLinkedDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", resp, "Failure sending next results request") + } + result, err = client.ListLinkedDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListLinkedDatabasesComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncAgentsClient) ListLinkedDatabasesComplete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListLinkedDatabases") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListLinkedDatabases(ctx, resourceGroupName, serverName, syncAgentName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/syncgroups.go b/services/preview/sql/mgmt/v3.0/sql/syncgroups.go new file mode 100644 index 000000000000..06cfc2c9a827 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/syncgroups.go @@ -0,0 +1,1107 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SyncGroupsClient 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 SyncGroupsClient struct { + BaseClient +} + +// NewSyncGroupsClient creates an instance of the SyncGroupsClient client. +func NewSyncGroupsClient(subscriptionID string) SyncGroupsClient { + return NewSyncGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncGroupsClientWithBaseURI creates an instance of the SyncGroupsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient { + return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CancelSync cancels a sync group synchronization. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) CancelSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.CancelSync") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelSyncPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSyncSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure sending request") + return + } + + result, err = client.CancelSyncResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure responding to request") + return + } + + return +} + +// CancelSyncPreparer prepares the CancelSync request. +func (client SyncGroupsClient) CancelSyncPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSyncSender sends the CancelSync request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) CancelSyncSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelSyncResponder handles the response to the CancelSync request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CancelSyncResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// parameters - the requested sync group resource state. +func (client SyncGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (result SyncGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SyncGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) CreateOrUpdateSender(req *http.Request) (future SyncGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) DeleteSender(req *http.Request) (future SyncGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "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.SyncGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) GetResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists sync groups under a hub database. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +func (client SyncGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.sglr.Response.Response != nil { + sc = result.sglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.sglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.sglr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.sglr.hasNextLink() && result.sglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client SyncGroupsClient) ListByDatabasePreparer(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 = "2019-06-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}/syncGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListByDatabaseResponder(resp *http.Response) (result SyncGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listByDatabaseNextResults(ctx context.Context, lastResults SyncGroupListResult) (result SyncGroupListResult, err error) { + req, err := lastResults.syncGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// ListHubSchemas gets a collection of hub database schemas. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListHubSchemas") + defer func() { + sc := -1 + if result.sfsplr.Response.Response != nil { + sc = result.sfsplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listHubSchemasNextResults + req, err := client.ListHubSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", nil, "Failure preparing request") + return + } + + resp, err := client.ListHubSchemasSender(req) + if err != nil { + result.sfsplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure sending request") + return + } + + result.sfsplr, err = client.ListHubSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure responding to request") + return + } + if result.sfsplr.hasNextLink() && result.sfsplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListHubSchemasPreparer prepares the ListHubSchemas request. +func (client SyncGroupsClient) ListHubSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/syncGroups/{syncGroupName}/hubSchemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListHubSchemasSender sends the ListHubSchemas request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListHubSchemasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListHubSchemasResponder handles the response to the ListHubSchemas request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListHubSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listHubSchemasNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listHubSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListHubSchemasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", resp, "Failure sending next results request") + } + result, err = client.ListHubSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListHubSchemasComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListHubSchemas") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListHubSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListLogs gets a collection of sync group logs. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// startTime - get logs generated after this time. +// endTime - get logs generated before this time. +// typeParameter - the types of logs to retrieve. +// continuationToken - the continuation token for this operation. +func (client SyncGroupsClient) ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") + defer func() { + sc := -1 + if result.sgllr.Response.Response != nil { + sc = result.sgllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listLogsNextResults + req, err := client.ListLogsPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", nil, "Failure preparing request") + return + } + + resp, err := client.ListLogsSender(req) + if err != nil { + result.sgllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure sending request") + return + } + + result.sgllr, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure responding to request") + return + } + if result.sgllr.hasNextLink() && result.sgllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListLogsPreparer prepares the ListLogs request. +func (client SyncGroupsClient) ListLogsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "endTime": autorest.Encode("query", endTime), + "startTime": autorest.Encode("query", startTime), + "type": autorest.Encode("query", typeParameter), + } + if len(continuationToken) > 0 { + queryParameters["continuationToken"] = autorest.Encode("query", continuationToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLogsSender sends the ListLogs request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListLogsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListLogsResponder handles the response to the ListLogs request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListLogsResponder(resp *http.Response) (result SyncGroupLogListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listLogsNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listLogsNextResults(ctx context.Context, lastResults SyncGroupLogListResult) (result SyncGroupLogListResult, err error) { + req, err := lastResults.syncGroupLogListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListLogsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListLogsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListLogs(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + return +} + +// ListSyncDatabaseIds gets a collection of sync database ids. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client SyncGroupsClient) ListSyncDatabaseIds(ctx context.Context, locationName string) (result SyncDatabaseIDListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListSyncDatabaseIds") + defer func() { + sc := -1 + if result.sdilr.Response.Response != nil { + sc = result.sdilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listSyncDatabaseIdsNextResults + req, err := client.ListSyncDatabaseIdsPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", nil, "Failure preparing request") + return + } + + resp, err := client.ListSyncDatabaseIdsSender(req) + if err != nil { + result.sdilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure sending request") + return + } + + result.sdilr, err = client.ListSyncDatabaseIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure responding to request") + return + } + if result.sdilr.hasNextLink() && result.sdilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListSyncDatabaseIdsPreparer prepares the ListSyncDatabaseIds request. +func (client SyncGroupsClient) ListSyncDatabaseIdsPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSyncDatabaseIdsSender sends the ListSyncDatabaseIds request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListSyncDatabaseIdsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSyncDatabaseIdsResponder handles the response to the ListSyncDatabaseIds request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListSyncDatabaseIdsResponder(resp *http.Response) (result SyncDatabaseIDListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listSyncDatabaseIdsNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listSyncDatabaseIdsNextResults(ctx context.Context, lastResults SyncDatabaseIDListResult) (result SyncDatabaseIDListResult, err error) { + req, err := lastResults.syncDatabaseIDListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSyncDatabaseIdsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListSyncDatabaseIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListSyncDatabaseIdsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result SyncDatabaseIDListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListSyncDatabaseIds") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListSyncDatabaseIds(ctx, locationName) + return +} + +// RefreshHubSchema refreshes a hub database schema. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroupsRefreshHubSchemaFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.RefreshHubSchema") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RefreshHubSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", nil, "Failure preparing request") + return + } + + result, err = client.RefreshHubSchemaSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", result.Response(), "Failure sending request") + return + } + + return +} + +// RefreshHubSchemaPreparer prepares the RefreshHubSchema request. +func (client SyncGroupsClient) RefreshHubSchemaPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshHubSchemaSender sends the RefreshHubSchema request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) RefreshHubSchemaSender(req *http.Request) (future SyncGroupsRefreshHubSchemaFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshHubSchemaResponder handles the response to the RefreshHubSchema request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) RefreshHubSchemaResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// TriggerSync triggers a sync group synchronization. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) TriggerSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.TriggerSync") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TriggerSyncPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", nil, "Failure preparing request") + return + } + + resp, err := client.TriggerSyncSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure sending request") + return + } + + result, err = client.TriggerSyncResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure responding to request") + return + } + + return +} + +// TriggerSyncPreparer prepares the TriggerSync request. +func (client SyncGroupsClient) TriggerSyncPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TriggerSyncSender sends the TriggerSync request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) TriggerSyncSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// TriggerSyncResponder handles the response to the TriggerSync request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) TriggerSyncResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates a sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// parameters - the requested sync group resource state. +func (client SyncGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (result SyncGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SyncGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) UpdateSender(req *http.Request) (future SyncGroupsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) UpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/syncmembers.go b/services/preview/sql/mgmt/v3.0/sql/syncmembers.go new file mode 100644 index 000000000000..bd0f57c649be --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/syncmembers.go @@ -0,0 +1,712 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// SyncMembersClient 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 SyncMembersClient struct { + BaseClient +} + +// NewSyncMembersClient creates an instance of the SyncMembersClient client. +func NewSyncMembersClient(subscriptionID string) SyncMembersClient { + return NewSyncMembersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncMembersClientWithBaseURI creates an instance of the SyncMembersClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncMembersClientWithBaseURI(baseURI string, subscriptionID string) SyncMembersClient { + return SyncMembersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +// parameters - the requested sync member resource state. +func (client SyncMembersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SyncMembersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) CreateOrUpdateSender(req *http.Request) (future SyncMembersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) CreateOrUpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncMembersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) DeleteSender(req *http.Request) (future SyncMembersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMember, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "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.SyncMembersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncMembersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2019-06-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}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) GetResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncGroup lists sync members in the given sync group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncMembersClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.smlr.Response.Response != nil { + sc = result.smlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySyncGroupNextResults + req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.smlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure sending request") + return + } + + result.smlr, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure responding to request") + return + } + if result.smlr.hasNextLink() && result.smlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySyncGroupPreparer prepares the ListBySyncGroup request. +func (client SyncMembersClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-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}/syncGroups/{syncGroupName}/syncMembers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) ListBySyncGroupResponder(resp *http.Response) (result SyncMemberListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySyncGroupNextResults retrieves the next set of results, if any. +func (client SyncMembersClient) listBySyncGroupNextResults(ctx context.Context, lastResults SyncMemberListResult) (result SyncMemberListResult, err error) { + req, err := lastResults.syncMemberListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySyncGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncMembersClient) ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySyncGroup(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListMemberSchemas gets a sync member database schema. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas") + defer func() { + sc := -1 + if result.sfsplr.Response.Response != nil { + sc = result.sfsplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listMemberSchemasNextResults + req, err := client.ListMemberSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", nil, "Failure preparing request") + return + } + + resp, err := client.ListMemberSchemasSender(req) + if err != nil { + result.sfsplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure sending request") + return + } + + result.sfsplr, err = client.ListMemberSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure responding to request") + return + } + if result.sfsplr.hasNextLink() && result.sfsplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListMemberSchemasPreparer prepares the ListMemberSchemas request. +func (client SyncMembersClient) ListMemberSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2019-06-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}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMemberSchemasSender sends the ListMemberSchemas request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) ListMemberSchemasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMemberSchemasResponder handles the response to the ListMemberSchemas request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) ListMemberSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listMemberSchemasNextResults retrieves the next set of results, if any. +func (client SyncMembersClient) listMemberSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListMemberSchemasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure sending next results request") + } + result, err = client.ListMemberSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListMemberSchemasComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncMembersClient) ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListMemberSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + return +} + +// RefreshMemberSchema refreshes a sync member database schema. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersRefreshMemberSchemaFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.RefreshMemberSchema") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RefreshMemberSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", nil, "Failure preparing request") + return + } + + result, err = client.RefreshMemberSchemaSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", result.Response(), "Failure sending request") + return + } + + return +} + +// RefreshMemberSchemaPreparer prepares the RefreshMemberSchema request. +func (client SyncMembersClient) RefreshMemberSchemaPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName 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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshMemberSchemaSender sends the RefreshMemberSchema request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) RefreshMemberSchemaSender(req *http.Request) (future SyncMembersRefreshMemberSchemaFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshMemberSchemaResponder handles the response to the RefreshMemberSchema request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) RefreshMemberSchemaResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing sync member. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +// parameters - the requested sync member resource state. +func (client SyncMembersClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SyncMembersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (*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), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", 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 SyncMembersClient) UpdateSender(req *http.Request) (future SyncMembersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) UpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/tdecertificates.go b/services/preview/sql/mgmt/v3.0/sql/tdecertificates.go new file mode 100644 index 000000000000..ab35584ea1b0 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/tdecertificates.go @@ -0,0 +1,123 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TdeCertificatesClient 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 TdeCertificatesClient struct { + BaseClient +} + +// NewTdeCertificatesClient creates an instance of the TdeCertificatesClient client. +func NewTdeCertificatesClient(subscriptionID string) TdeCertificatesClient { + return NewTdeCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTdeCertificatesClientWithBaseURI creates an instance of the TdeCertificatesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTdeCertificatesClientWithBaseURI(baseURI string, subscriptionID string) TdeCertificatesClient { + return TdeCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a TDE certificate for a given server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the requested TDE certificate to be created or updated. +func (client TdeCertificatesClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters TdeCertificate) (result TdeCertificatesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TdeCertificatesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TdeCertificateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TdeCertificateProperties.PrivateBlob", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.TdeCertificatesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TdeCertificatesClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters TdeCertificate) (*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-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates", pathParameters), + autorest.WithJSON(parameters), + 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 TdeCertificatesClient) CreateSender(req *http.Request) (future TdeCertificatesCreateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TdeCertificatesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/transparentdataencryptionactivities.go b/services/preview/sql/mgmt/v3.0/sql/transparentdataencryptionactivities.go new file mode 100644 index 000000000000..309e0d47eb0d --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/transparentdataencryptionactivities.go @@ -0,0 +1,115 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// TransparentDataEncryptionActivitiesClient 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 TransparentDataEncryptionActivitiesClient struct { + BaseClient +} + +// NewTransparentDataEncryptionActivitiesClient creates an instance of the TransparentDataEncryptionActivitiesClient +// client. +func NewTransparentDataEncryptionActivitiesClient(subscriptionID string) TransparentDataEncryptionActivitiesClient { + return NewTransparentDataEncryptionActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransparentDataEncryptionActivitiesClientWithBaseURI creates an instance of the +// TransparentDataEncryptionActivitiesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTransparentDataEncryptionActivitiesClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionActivitiesClient { + return TransparentDataEncryptionActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByConfiguration returns a database's transparent data encryption operation result. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionActivitiesClient) ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionActivitiesClient.ListByConfiguration") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByConfigurationPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure sending request") + return + } + + result, err = client.ListByConfigurationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure responding to request") + return + } + + return +} + +// ListByConfigurationPreparer prepares the ListByConfiguration request. +func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationPreparer(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), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + 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}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationSender sends the ListByConfiguration request. The method will close the +// http.Response Body if it receives an error. +func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationResponder handles the response to the ListByConfiguration request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationResponder(resp *http.Response) (result TransparentDataEncryptionActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/transparentdataencryptions.go b/services/preview/sql/mgmt/v3.0/sql/transparentdataencryptions.go new file mode 100644 index 000000000000..691b41cd1464 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/transparentdataencryptions.go @@ -0,0 +1,198 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// TransparentDataEncryptionsClient 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 TransparentDataEncryptionsClient struct { + BaseClient +} + +// NewTransparentDataEncryptionsClient creates an instance of the TransparentDataEncryptionsClient client. +func NewTransparentDataEncryptionsClient(subscriptionID string) TransparentDataEncryptionsClient { + return NewTransparentDataEncryptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransparentDataEncryptionsClientWithBaseURI creates an instance of the TransparentDataEncryptionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewTransparentDataEncryptionsClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionsClient { + return TransparentDataEncryptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which setting the transparent data encryption applies. +// parameters - the required parameters for creating or updating transparent data encryption. +func (client TransparentDataEncryptionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (result TransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "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.TransparentDataEncryptionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TransparentDataEncryptionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (*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), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}", 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 TransparentDataEncryptionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "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.TransparentDataEncryptionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TransparentDataEncryptionsClient) 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), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + 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}/transparentDataEncryption/{transparentDataEncryptionName}", 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 TransparentDataEncryptionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/usages.go b/services/preview/sql/mgmt/v3.0/sql/usages.go new file mode 100644 index 000000000000..5afa6c8dc189 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/usages.go @@ -0,0 +1,156 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// UsagesClient 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 UsagesClient struct { + BaseClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByInstancePool gets all instance pool usage metrics +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be retrieved. +// expandChildren - optional request parameter to include managed instance usages within the instance pool. +func (client UsagesClient) ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result UsageListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.ulr.Response.Response != nil { + sc = result.ulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstancePoolNextResults + req, err := client.ListByInstancePoolPreparer(ctx, resourceGroupName, instancePoolName, expandChildren) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "ListByInstancePool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.ulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "ListByInstancePool", resp, "Failure sending request") + return + } + + result.ulr, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "ListByInstancePool", resp, "Failure responding to request") + return + } + if result.ulr.hasNextLink() && result.ulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePoolPreparer prepares the ListByInstancePool request. +func (client UsagesClient) ListByInstancePoolPreparer(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if expandChildren != nil { + queryParameters["expandChildren"] = autorest.Encode("query", *expandChildren) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstancePoolSender sends the ListByInstancePool request. The method will close the +// http.Response Body if it receives an error. +func (client UsagesClient) ListByInstancePoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstancePoolResponder handles the response to the ListByInstancePool request. The method always +// closes the http.Response Body. +func (client UsagesClient) ListByInstancePoolResponder(resp *http.Response) (result UsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstancePoolNextResults retrieves the next set of results, if any. +func (client UsagesClient) listByInstancePoolNextResults(ctx context.Context, lastResults UsageListResult) (result UsageListResult, err error) { + req, err := lastResults.usageListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.UsagesClient", "listByInstancePoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.UsagesClient", "listByInstancePoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "listByInstancePoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstancePoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client UsagesClient) ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result UsageListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstancePool(ctx, resourceGroupName, instancePoolName, expandChildren) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/version.go b/services/preview/sql/mgmt/v3.0/sql/version.go new file mode 100644 index 000000000000..ce5cf4c1e32c --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/version.go @@ -0,0 +1,19 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " sql/v3.0" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/sql/mgmt/v3.0/sql/virtualclusters.go b/services/preview/sql/mgmt/v3.0/sql/virtualclusters.go new file mode 100644 index 000000000000..a5f661baaf7b --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/virtualclusters.go @@ -0,0 +1,502 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// VirtualClustersClient 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 VirtualClustersClient struct { + BaseClient +} + +// NewVirtualClustersClient creates an instance of the VirtualClustersClient client. +func NewVirtualClustersClient(subscriptionID string) VirtualClustersClient { + return NewVirtualClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualClustersClientWithBaseURI creates an instance of the VirtualClustersClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVirtualClustersClientWithBaseURI(baseURI string, subscriptionID string) VirtualClustersClient { + return VirtualClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) Delete(ctx context.Context, resourceGroupName string, virtualClusterName string) (result VirtualClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2015-05-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/virtualClusters/{virtualClusterName}", 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 VirtualClustersClient) DeleteSender(req *http.Request) (future VirtualClustersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) Get(ctx context.Context, resourceGroupName string, virtualClusterName string) (result VirtualCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "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.VirtualClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + 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/virtualClusters/{virtualClusterName}", 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 VirtualClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) GetResponder(resp *http.Response) (result VirtualCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all virtualClusters in the subscription. +func (client VirtualClustersClient) List(ctx context.Context) (result VirtualClusterListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.List") + defer func() { + sc := -1 + if result.vclr.Response.Response != nil { + sc = result.vclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.vclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", resp, "Failure sending request") + return + } + + result.vclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", resp, "Failure responding to request") + return + } + if result.vclr.hasNextLink() && result.vclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "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}/providers/Microsoft.Sql/virtualClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) ListResponder(resp *http.Response) (result VirtualClusterListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client VirtualClustersClient) listNextResults(ctx context.Context, lastResults VirtualClusterListResult) (result VirtualClusterListResult, err error) { + req, err := lastResults.virtualClusterListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualClustersClient) ListComplete(ctx context.Context) (result VirtualClusterListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of virtual clusters in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client VirtualClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result VirtualClusterListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.vclr.Response.Response != nil { + sc = result.vclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.vclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.vclr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.vclr.hasNextLink() && result.vclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client VirtualClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "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/virtualClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) ListByResourceGroupResponder(resp *http.Response) (result VirtualClusterListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client VirtualClustersClient) listByResourceGroupNextResults(ctx context.Context, lastResults VirtualClusterListResult) (result VirtualClusterListResult, err error) { + req, err := lastResults.virtualClusterListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualClustersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result VirtualClusterListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +// parameters - the requested managed instance resource state. +func (client VirtualClustersClient) Update(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters VirtualClusterUpdate) (result VirtualClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, virtualClusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters VirtualClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", 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 VirtualClustersClient) UpdateSender(req *http.Request) (future VirtualClustersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) UpdateResponder(resp *http.Response) (result VirtualCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/virtualnetworkrules.go b/services/preview/sql/mgmt/v3.0/sql/virtualnetworkrules.go new file mode 100644 index 000000000000..91880b34fb82 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/virtualnetworkrules.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VirtualNetworkRulesClient 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 VirtualNetworkRulesClient struct { + BaseClient +} + +// NewVirtualNetworkRulesClient creates an instance of the VirtualNetworkRulesClient client. +func NewVirtualNetworkRulesClient(subscriptionID string) VirtualNetworkRulesClient { + return NewVirtualNetworkRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworkRulesClientWithBaseURI creates an instance of the VirtualNetworkRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewVirtualNetworkRulesClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkRulesClient { + return VirtualNetworkRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing virtual network rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +// parameters - the requested virtual Network Rule Resource state. +func (client VirtualNetworkRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule) (result VirtualNetworkRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkRuleProperties.VirtualNetworkSubnetID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.VirtualNetworkRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VirtualNetworkRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", 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 VirtualNetworkRulesClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the virtual network rule with the given name. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualNetworkRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + const APIVersion = "2015-05-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}/virtualNetworkRules/{virtualNetworkRuleName}", 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 VirtualNetworkRulesClient) DeleteSender(req *http.Request) (future VirtualNetworkRulesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual network rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "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.VirtualNetworkRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualNetworkRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + 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}/virtualNetworkRules/{virtualNetworkRuleName}", 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 VirtualNetworkRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) GetResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of virtual network rules in a server. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.ListByServer") + defer func() { + sc := -1 + if result.vnrlr.Response.Response != nil { + sc = result.vnrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.vnrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.vnrlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.vnrlr.hasNextLink() && result.vnrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client VirtualNetworkRulesClient) 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 = "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}/virtualNetworkRules", 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 VirtualNetworkRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) ListByServerResponder(resp *http.Response) (result VirtualNetworkRuleListResult, err error) { + err = autorest.Respond( + resp, + 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 VirtualNetworkRulesClient) listByServerNextResults(ctx context.Context, lastResults VirtualNetworkRuleListResult) (result VirtualNetworkRuleListResult, err error) { + req, err := lastResults.virtualNetworkRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "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.VirtualNetworkRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualNetworkRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/workloadclassifiers.go b/services/preview/sql/mgmt/v3.0/sql/workloadclassifiers.go new file mode 100644 index 000000000000..30827c6f9a7b --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/workloadclassifiers.go @@ -0,0 +1,422 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkloadClassifiersClient 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 WorkloadClassifiersClient struct { + BaseClient +} + +// NewWorkloadClassifiersClient creates an instance of the WorkloadClassifiersClient client. +func NewWorkloadClassifiersClient(subscriptionID string) WorkloadClassifiersClient { + return NewWorkloadClassifiersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkloadClassifiersClientWithBaseURI creates an instance of the WorkloadClassifiersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewWorkloadClassifiersClientWithBaseURI(baseURI string, subscriptionID string) WorkloadClassifiersClient { + return WorkloadClassifiersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a workload classifier. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifier from. +// workloadClassifierName - the name of the workload classifier to create/update. +// parameters - the properties of the workload classifier. +func (client WorkloadClassifiersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string, parameters WorkloadClassifier) (result WorkloadClassifiersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.WorkloadClassifierProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.WorkloadClassifierProperties.MemberName", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.WorkloadClassifiersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, workloadClassifierName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkloadClassifiersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string, parameters WorkloadClassifier) (*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), + "workloadClassifierName": autorest.Encode("path", workloadClassifierName), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", 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 WorkloadClassifiersClient) CreateOrUpdateSender(req *http.Request) (future WorkloadClassifiersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) CreateOrUpdateResponder(resp *http.Response) (result WorkloadClassifier, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a workload classifier. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifier from. +// workloadClassifierName - the name of the workload classifier to delete. +func (client WorkloadClassifiersClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result WorkloadClassifiersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, workloadClassifierName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkloadClassifiersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName 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), + "workloadClassifierName": autorest.Encode("path", workloadClassifierName), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", 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 WorkloadClassifiersClient) DeleteSender(req *http.Request) (future WorkloadClassifiersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a workload classifier +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifier from. +// workloadClassifierName - the name of the workload classifier. +func (client WorkloadClassifiersClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result WorkloadClassifier, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, workloadClassifierName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "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.WorkloadClassifiersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkloadClassifiersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName 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), + "workloadClassifierName": autorest.Encode("path", workloadClassifierName), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-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}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", 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 WorkloadClassifiersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) GetResponder(resp *http.Response) (result WorkloadClassifier, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkloadGroup gets the list of workload classifiers for a workload group +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifiers from. +func (client WorkloadClassifiersClient) ListByWorkloadGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadClassifierListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.ListByWorkloadGroup") + defer func() { + sc := -1 + if result.wclr.Response.Response != nil { + sc = result.wclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByWorkloadGroupNextResults + req, err := client.ListByWorkloadGroupPreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "ListByWorkloadGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkloadGroupSender(req) + if err != nil { + result.wclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "ListByWorkloadGroup", resp, "Failure sending request") + return + } + + result.wclr, err = client.ListByWorkloadGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "ListByWorkloadGroup", resp, "Failure responding to request") + return + } + if result.wclr.hasNextLink() && result.wclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByWorkloadGroupPreparer prepares the ListByWorkloadGroup request. +func (client WorkloadClassifiersClient) ListByWorkloadGroupPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName 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), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-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}/workloadGroups/{workloadGroupName}/workloadClassifiers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkloadGroupSender sends the ListByWorkloadGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadClassifiersClient) ListByWorkloadGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkloadGroupResponder handles the response to the ListByWorkloadGroup request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) ListByWorkloadGroupResponder(resp *http.Response) (result WorkloadClassifierListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByWorkloadGroupNextResults retrieves the next set of results, if any. +func (client WorkloadClassifiersClient) listByWorkloadGroupNextResults(ctx context.Context, lastResults WorkloadClassifierListResult) (result WorkloadClassifierListResult, err error) { + req, err := lastResults.workloadClassifierListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "listByWorkloadGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByWorkloadGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "listByWorkloadGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByWorkloadGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "listByWorkloadGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByWorkloadGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadClassifiersClient) ListByWorkloadGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadClassifierListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.ListByWorkloadGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByWorkloadGroup(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + return +} diff --git a/services/preview/sql/mgmt/v3.0/sql/workloadgroups.go b/services/preview/sql/mgmt/v3.0/sql/workloadgroups.go new file mode 100644 index 000000000000..2c492cae55e1 --- /dev/null +++ b/services/preview/sql/mgmt/v3.0/sql/workloadgroups.go @@ -0,0 +1,416 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkloadGroupsClient 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 WorkloadGroupsClient struct { + BaseClient +} + +// NewWorkloadGroupsClient creates an instance of the WorkloadGroupsClient client. +func NewWorkloadGroupsClient(subscriptionID string) WorkloadGroupsClient { + return NewWorkloadGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkloadGroupsClientWithBaseURI creates an instance of the WorkloadGroupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWorkloadGroupsClientWithBaseURI(baseURI string, subscriptionID string) WorkloadGroupsClient { + return WorkloadGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a workload group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group. +// parameters - the requested workload group state. +func (client WorkloadGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, parameters WorkloadGroup) (result WorkloadGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.WorkloadGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.WorkloadGroupProperties.MinResourcePercent", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WorkloadGroupProperties.MaxResourcePercent", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WorkloadGroupProperties.MinResourcePercentPerRequest", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.WorkloadGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkloadGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, parameters WorkloadGroup) (*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), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", 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 WorkloadGroupsClient) CreateOrUpdateSender(req *http.Request) (future WorkloadGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result WorkloadGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a workload group. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group to delete. +func (client WorkloadGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkloadGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName 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), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-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}/databases/{databaseName}/workloadGroups/{workloadGroupName}", 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 WorkloadGroupsClient) DeleteSender(req *http.Request) (future WorkloadGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a workload group +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group. +func (client WorkloadGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "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.WorkloadGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkloadGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName 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), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2019-06-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}/workloadGroups/{workloadGroupName}", 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 WorkloadGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) GetResponder(resp *http.Response) (result WorkloadGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets the list of workload groups +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client WorkloadGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result WorkloadGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.wglr.Response.Response != nil { + sc = result.wglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.wglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.wglr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.wglr.hasNextLink() && result.wglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client WorkloadGroupsClient) ListByDatabasePreparer(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 = "2019-06-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}/workloadGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadGroupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) ListByDatabaseResponder(resp *http.Response) (result WorkloadGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client WorkloadGroupsClient) listByDatabaseNextResults(ctx context.Context, lastResults WorkloadGroupListResult) (result WorkloadGroupListResult, err error) { + req, err := lastResults.workloadGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadGroupsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result WorkloadGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v4.0/sql/CHANGELOG.md b/services/preview/sql/mgmt/v4.0/sql/CHANGELOG.md index 52911e4cc5e4..0e6c7a6ac2ec 100644 --- a/services/preview/sql/mgmt/v4.0/sql/CHANGELOG.md +++ b/services/preview/sql/mgmt/v4.0/sql/CHANGELOG.md @@ -1,2 +1,336 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Constants + +1. DatabaseState2.DatabaseState2All +1. DatabaseState2.DatabaseState2Deleted +1. DatabaseState2.DatabaseState2Live +1. DatabaseState3.DatabaseState3All +1. DatabaseState3.DatabaseState3Deleted +1. DatabaseState3.DatabaseState3Live +1. DatabaseState4.DatabaseState4All +1. DatabaseState4.DatabaseState4Deleted +1. DatabaseState4.DatabaseState4Live +1. DatabaseState5.DatabaseState5All +1. DatabaseState5.DatabaseState5Deleted +1. DatabaseState5.DatabaseState5Live +1. DatabaseState6.DatabaseState6All +1. DatabaseState6.DatabaseState6Deleted +1. DatabaseState6.DatabaseState6Live +1. LongTermRetentionDatabaseState.LongTermRetentionDatabaseStateAll +1. LongTermRetentionDatabaseState.LongTermRetentionDatabaseStateDeleted +1. LongTermRetentionDatabaseState.LongTermRetentionDatabaseStateLive +1. SecondaryType.Named + +### Removed Funcs + +1. *BackupLongTermRetentionPoliciesCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *BackupLongTermRetentionPolicy.UnmarshalJSON([]byte) error +1. BackupLongTermRetentionPoliciesClient.CreateOrUpdate(context.Context, string, string, string, BackupLongTermRetentionPolicy) (BackupLongTermRetentionPoliciesCreateOrUpdateFuture, error) +1. BackupLongTermRetentionPoliciesClient.CreateOrUpdatePreparer(context.Context, string, string, string, BackupLongTermRetentionPolicy) (*http.Request, error) +1. BackupLongTermRetentionPoliciesClient.CreateOrUpdateResponder(*http.Response) (BackupLongTermRetentionPolicy, error) +1. BackupLongTermRetentionPoliciesClient.CreateOrUpdateSender(*http.Request) (BackupLongTermRetentionPoliciesCreateOrUpdateFuture, error) +1. BackupLongTermRetentionPoliciesClient.Get(context.Context, string, string, string) (BackupLongTermRetentionPolicy, error) +1. BackupLongTermRetentionPoliciesClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. BackupLongTermRetentionPoliciesClient.GetResponder(*http.Response) (BackupLongTermRetentionPolicy, error) +1. BackupLongTermRetentionPoliciesClient.GetSender(*http.Request) (*http.Response, error) +1. BackupLongTermRetentionPoliciesClient.ListByDatabase(context.Context, string, string, string) (BackupLongTermRetentionPolicy, error) +1. BackupLongTermRetentionPoliciesClient.ListByDatabasePreparer(context.Context, string, string, string) (*http.Request, error) +1. BackupLongTermRetentionPoliciesClient.ListByDatabaseResponder(*http.Response) (BackupLongTermRetentionPolicy, error) +1. BackupLongTermRetentionPoliciesClient.ListByDatabaseSender(*http.Request) (*http.Response, error) +1. BackupLongTermRetentionPolicy.MarshalJSON() ([]byte, error) +1. NewBackupLongTermRetentionPoliciesClient(string) BackupLongTermRetentionPoliciesClient +1. NewBackupLongTermRetentionPoliciesClientWithBaseURI(string, string) BackupLongTermRetentionPoliciesClient +1. PossibleDatabaseState1Values() []DatabaseState1 +1. PossibleDatabaseState2Values() []DatabaseState2 +1. PossibleDatabaseState3Values() []DatabaseState3 +1. PossibleDatabaseState4Values() []DatabaseState4 +1. PossibleDatabaseState5Values() []DatabaseState5 +1. PossibleDatabaseState6Values() []DatabaseState6 +1. PossibleLongTermRetentionDatabaseStateValues() []LongTermRetentionDatabaseState +1. SystemData.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### Removed Structs + +1. BackupLongTermRetentionPoliciesClient +1. BackupLongTermRetentionPoliciesCreateOrUpdateFuture +1. BackupLongTermRetentionPolicy +1. LongTermRetentionPolicyProperties + +#### Removed Struct Fields + +1. DatabaseProperties.StorageAccountType + +### Signature Changes + +#### Const Types + +1. All changed type from DatabaseState1 to DatabaseState +1. Deleted changed type from DatabaseState1 to DatabaseState +1. Geo changed type from SecondaryType to BackupStorageRedundancy +1. Live changed type from DatabaseState1 to DatabaseState + +#### Funcs + +1. LongTermRetentionBackupsClient.ListByDatabase + - Params + - From: context.Context, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByDatabaseComplete + - Params + - From: context.Context, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByDatabasePreparer + - Params + - From: context.Context, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByLocation + - Params + - From: context.Context, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByLocationComplete + - Params + - From: context.Context, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByLocationPreparer + - Params + - From: context.Context, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupDatabase + - Params + - From: context.Context, string, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupDatabaseComplete + - Params + - From: context.Context, string, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupDatabasePreparer + - Params + - From: context.Context, string, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupLocation + - Params + - From: context.Context, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupLocationComplete + - Params + - From: context.Context, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupLocationPreparer + - Params + - From: context.Context, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupServer + - Params + - From: context.Context, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupServerComplete + - Params + - From: context.Context, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByResourceGroupServerPreparer + - Params + - From: context.Context, string, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByServer + - Params + - From: context.Context, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByServerComplete + - Params + - From: context.Context, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionBackupsClient.ListByServerPreparer + - Params + - From: context.Context, string, string, *bool, LongTermRetentionDatabaseState + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByDatabase + - Params + - From: context.Context, string, string, string, *bool, DatabaseState1 + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByDatabaseComplete + - Params + - From: context.Context, string, string, string, *bool, DatabaseState1 + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByDatabasePreparer + - Params + - From: context.Context, string, string, string, *bool, DatabaseState1 + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByInstance + - Params + - From: context.Context, string, string, *bool, DatabaseState2 + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByInstanceComplete + - Params + - From: context.Context, string, string, *bool, DatabaseState2 + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByInstancePreparer + - Params + - From: context.Context, string, string, *bool, DatabaseState2 + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByLocation + - Params + - From: context.Context, string, *bool, DatabaseState3 + - To: context.Context, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByLocationComplete + - Params + - From: context.Context, string, *bool, DatabaseState3 + - To: context.Context, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByLocationPreparer + - Params + - From: context.Context, string, *bool, DatabaseState3 + - To: context.Context, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase + - Params + - From: context.Context, string, string, string, string, *bool, DatabaseState4 + - To: context.Context, string, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabaseComplete + - Params + - From: context.Context, string, string, string, string, *bool, DatabaseState4 + - To: context.Context, string, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabasePreparer + - Params + - From: context.Context, string, string, string, string, *bool, DatabaseState4 + - To: context.Context, string, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance + - Params + - From: context.Context, string, string, string, *bool, DatabaseState5 + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstanceComplete + - Params + - From: context.Context, string, string, string, *bool, DatabaseState5 + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstancePreparer + - Params + - From: context.Context, string, string, string, *bool, DatabaseState5 + - To: context.Context, string, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation + - Params + - From: context.Context, string, string, *bool, DatabaseState6 + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocationComplete + - Params + - From: context.Context, string, string, *bool, DatabaseState6 + - To: context.Context, string, string, *bool, DatabaseState +1. LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocationPreparer + - Params + - From: context.Context, string, string, *bool, DatabaseState6 + - To: context.Context, string, string, *bool, DatabaseState + +## Additive Changes + +### New Constants + +1. BackupStorageRedundancy.Local +1. BackupStorageRedundancy.Zone +1. CurrentBackupStorageRedundancy.CurrentBackupStorageRedundancyGeo +1. CurrentBackupStorageRedundancy.CurrentBackupStorageRedundancyLocal +1. CurrentBackupStorageRedundancy.CurrentBackupStorageRedundancyZone +1. IdentityType.SystemAssignedUserAssigned +1. RequestedBackupStorageRedundancy.RequestedBackupStorageRedundancyGeo +1. RequestedBackupStorageRedundancy.RequestedBackupStorageRedundancyLocal +1. RequestedBackupStorageRedundancy.RequestedBackupStorageRedundancyZone +1. SecondaryType.SecondaryTypeGeo +1. SecondaryType.SecondaryTypeNamed +1. TargetBackupStorageRedundancy.TargetBackupStorageRedundancyGeo +1. TargetBackupStorageRedundancy.TargetBackupStorageRedundancyLocal +1. TargetBackupStorageRedundancy.TargetBackupStorageRedundancyZone + +### New Funcs + +1. *CopyLongTermRetentionBackupParameters.UnmarshalJSON([]byte) error +1. *LongTermRetentionBackupOperationResult.UnmarshalJSON([]byte) error +1. *LongTermRetentionBackupsCopyByResourceGroupFuture.UnmarshalJSON([]byte) error +1. *LongTermRetentionBackupsCopyFuture.UnmarshalJSON([]byte) error +1. *LongTermRetentionBackupsUpdateByResourceGroupFuture.UnmarshalJSON([]byte) error +1. *LongTermRetentionBackupsUpdateFuture.UnmarshalJSON([]byte) error +1. *LongTermRetentionPoliciesCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *LongTermRetentionPolicy.UnmarshalJSON([]byte) error +1. *LongTermRetentionPolicyListResultIterator.Next() error +1. *LongTermRetentionPolicyListResultIterator.NextWithContext(context.Context) error +1. *LongTermRetentionPolicyListResultPage.Next() error +1. *LongTermRetentionPolicyListResultPage.NextWithContext(context.Context) error +1. *UpdateLongTermRetentionBackupParameters.UnmarshalJSON([]byte) error +1. CopyLongTermRetentionBackupParameters.MarshalJSON() ([]byte, error) +1. LongTermRetentionBackupOperationResult.MarshalJSON() ([]byte, error) +1. LongTermRetentionBackupsClient.Copy(context.Context, string, string, string, string, CopyLongTermRetentionBackupParameters) (LongTermRetentionBackupsCopyFuture, error) +1. LongTermRetentionBackupsClient.CopyByResourceGroup(context.Context, string, string, string, string, string, CopyLongTermRetentionBackupParameters) (LongTermRetentionBackupsCopyByResourceGroupFuture, error) +1. LongTermRetentionBackupsClient.CopyByResourceGroupPreparer(context.Context, string, string, string, string, string, CopyLongTermRetentionBackupParameters) (*http.Request, error) +1. LongTermRetentionBackupsClient.CopyByResourceGroupResponder(*http.Response) (LongTermRetentionBackupOperationResult, error) +1. LongTermRetentionBackupsClient.CopyByResourceGroupSender(*http.Request) (LongTermRetentionBackupsCopyByResourceGroupFuture, error) +1. LongTermRetentionBackupsClient.CopyPreparer(context.Context, string, string, string, string, CopyLongTermRetentionBackupParameters) (*http.Request, error) +1. LongTermRetentionBackupsClient.CopyResponder(*http.Response) (LongTermRetentionBackupOperationResult, error) +1. LongTermRetentionBackupsClient.CopySender(*http.Request) (LongTermRetentionBackupsCopyFuture, error) +1. LongTermRetentionBackupsClient.Update(context.Context, string, string, string, string, UpdateLongTermRetentionBackupParameters) (LongTermRetentionBackupsUpdateFuture, error) +1. LongTermRetentionBackupsClient.UpdateByResourceGroup(context.Context, string, string, string, string, string, UpdateLongTermRetentionBackupParameters) (LongTermRetentionBackupsUpdateByResourceGroupFuture, error) +1. LongTermRetentionBackupsClient.UpdateByResourceGroupPreparer(context.Context, string, string, string, string, string, UpdateLongTermRetentionBackupParameters) (*http.Request, error) +1. LongTermRetentionBackupsClient.UpdateByResourceGroupResponder(*http.Response) (LongTermRetentionBackupOperationResult, error) +1. LongTermRetentionBackupsClient.UpdateByResourceGroupSender(*http.Request) (LongTermRetentionBackupsUpdateByResourceGroupFuture, error) +1. LongTermRetentionBackupsClient.UpdatePreparer(context.Context, string, string, string, string, UpdateLongTermRetentionBackupParameters) (*http.Request, error) +1. LongTermRetentionBackupsClient.UpdateResponder(*http.Response) (LongTermRetentionBackupOperationResult, error) +1. LongTermRetentionBackupsClient.UpdateSender(*http.Request) (LongTermRetentionBackupsUpdateFuture, error) +1. LongTermRetentionOperationResultProperties.MarshalJSON() ([]byte, error) +1. LongTermRetentionPoliciesClient.CreateOrUpdate(context.Context, string, string, string, LongTermRetentionPolicy) (LongTermRetentionPoliciesCreateOrUpdateFuture, error) +1. LongTermRetentionPoliciesClient.CreateOrUpdatePreparer(context.Context, string, string, string, LongTermRetentionPolicy) (*http.Request, error) +1. LongTermRetentionPoliciesClient.CreateOrUpdateResponder(*http.Response) (LongTermRetentionPolicy, error) +1. LongTermRetentionPoliciesClient.CreateOrUpdateSender(*http.Request) (LongTermRetentionPoliciesCreateOrUpdateFuture, error) +1. LongTermRetentionPoliciesClient.Get(context.Context, string, string, string) (LongTermRetentionPolicy, error) +1. LongTermRetentionPoliciesClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. LongTermRetentionPoliciesClient.GetResponder(*http.Response) (LongTermRetentionPolicy, error) +1. LongTermRetentionPoliciesClient.GetSender(*http.Request) (*http.Response, error) +1. LongTermRetentionPoliciesClient.ListByDatabase(context.Context, string, string, string) (LongTermRetentionPolicyListResultPage, error) +1. LongTermRetentionPoliciesClient.ListByDatabaseComplete(context.Context, string, string, string) (LongTermRetentionPolicyListResultIterator, error) +1. LongTermRetentionPoliciesClient.ListByDatabasePreparer(context.Context, string, string, string) (*http.Request, error) +1. LongTermRetentionPoliciesClient.ListByDatabaseResponder(*http.Response) (LongTermRetentionPolicyListResult, error) +1. LongTermRetentionPoliciesClient.ListByDatabaseSender(*http.Request) (*http.Response, error) +1. LongTermRetentionPolicy.MarshalJSON() ([]byte, error) +1. LongTermRetentionPolicyListResult.IsEmpty() bool +1. LongTermRetentionPolicyListResult.MarshalJSON() ([]byte, error) +1. LongTermRetentionPolicyListResultIterator.NotDone() bool +1. LongTermRetentionPolicyListResultIterator.Response() LongTermRetentionPolicyListResult +1. LongTermRetentionPolicyListResultIterator.Value() LongTermRetentionPolicy +1. LongTermRetentionPolicyListResultPage.NotDone() bool +1. LongTermRetentionPolicyListResultPage.Response() LongTermRetentionPolicyListResult +1. LongTermRetentionPolicyListResultPage.Values() []LongTermRetentionPolicy +1. NewLongTermRetentionPoliciesClient(string) LongTermRetentionPoliciesClient +1. NewLongTermRetentionPoliciesClientWithBaseURI(string, string) LongTermRetentionPoliciesClient +1. NewLongTermRetentionPolicyListResultIterator(LongTermRetentionPolicyListResultPage) LongTermRetentionPolicyListResultIterator +1. NewLongTermRetentionPolicyListResultPage(LongTermRetentionPolicyListResult, func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error)) LongTermRetentionPolicyListResultPage +1. PossibleBackupStorageRedundancyValues() []BackupStorageRedundancy +1. PossibleCurrentBackupStorageRedundancyValues() []CurrentBackupStorageRedundancy +1. PossibleDatabaseStateValues() []DatabaseState +1. PossibleRequestedBackupStorageRedundancyValues() []RequestedBackupStorageRedundancy +1. PossibleTargetBackupStorageRedundancyValues() []TargetBackupStorageRedundancy +1. UpdateLongTermRetentionBackupParameters.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### New Structs + +1. CopyLongTermRetentionBackupParameters +1. CopyLongTermRetentionBackupParametersProperties +1. LongTermRetentionBackupOperationResult +1. LongTermRetentionBackupsCopyByResourceGroupFuture +1. LongTermRetentionBackupsCopyFuture +1. LongTermRetentionBackupsUpdateByResourceGroupFuture +1. LongTermRetentionBackupsUpdateFuture +1. LongTermRetentionOperationResultProperties +1. LongTermRetentionPoliciesClient +1. LongTermRetentionPoliciesCreateOrUpdateFuture +1. LongTermRetentionPolicy +1. LongTermRetentionPolicyListResult +1. LongTermRetentionPolicyListResultIterator +1. LongTermRetentionPolicyListResultPage +1. UpdateLongTermRetentionBackupParameters +1. UpdateLongTermRetentionBackupParametersProperties + +#### New Struct Fields + +1. DatabaseProperties.CurrentBackupStorageRedundancy +1. DatabaseProperties.RequestedBackupStorageRedundancy +1. LongTermRetentionBackupProperties.BackupStorageRedundancy +1. LongTermRetentionBackupProperties.RequestedBackupStorageRedundancy diff --git a/services/preview/sql/mgmt/v4.0/sql/_meta.json b/services/preview/sql/mgmt/v4.0/sql/_meta.json index bb735559bd7b..09e90d15b5f4 100644 --- a/services/preview/sql/mgmt/v4.0/sql/_meta.json +++ b/services/preview/sql/mgmt/v4.0/sql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "a1eee0489c374782a934ec1f093abd16fa7718ca", + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", "tag": "package-composite-v4", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/sql/mgmt/v4.0/sql/databases.go b/services/preview/sql/mgmt/v4.0/sql/databases.go index 95d7c44d9246..52dec36114dd 100644 --- a/services/preview/sql/mgmt/v4.0/sql/databases.go +++ b/services/preview/sql/mgmt/v4.0/sql/databases.go @@ -86,7 +86,7 @@ func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resour "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -172,7 +172,7 @@ func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -348,7 +348,7 @@ func (client DatabasesClient) FailoverPreparer(ctx context.Context, resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -439,7 +439,7 @@ func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -523,7 +523,7 @@ func (client DatabasesClient) ListByElasticPoolPreparer(ctx context.Context, res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -642,7 +642,7 @@ func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -761,7 +761,7 @@ func (client DatabasesClient) ListInaccessibleByServerPreparer(ctx context.Conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1030,7 +1030,7 @@ func (client DatabasesClient) PausePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1126,7 +1126,7 @@ func (client DatabasesClient) RenamePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1199,7 +1199,7 @@ func (client DatabasesClient) ResumePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1282,7 +1282,7 @@ func (client DatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1366,7 +1366,7 @@ func (client DatabasesClient) UpgradeDataWarehousePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-08-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v4.0/sql/enums.go b/services/preview/sql/mgmt/v4.0/sql/enums.go index eb3318b849a1..cc861f6c6013 100644 --- a/services/preview/sql/mgmt/v4.0/sql/enums.go +++ b/services/preview/sql/mgmt/v4.0/sql/enums.go @@ -137,6 +137,23 @@ func PossibleAutomaticTuningServerReasonValues() []AutomaticTuningServerReason { return []AutomaticTuningServerReason{AutomaticTuningServerReasonAutoConfigured, AutomaticTuningServerReasonDefault, AutomaticTuningServerReasonDisabled} } +// BackupStorageRedundancy enumerates the values for backup storage redundancy. +type BackupStorageRedundancy string + +const ( + // Geo ... + Geo BackupStorageRedundancy = "Geo" + // Local ... + Local BackupStorageRedundancy = "Local" + // Zone ... + Zone BackupStorageRedundancy = "Zone" +) + +// PossibleBackupStorageRedundancyValues returns an array of possible values for the BackupStorageRedundancy const type. +func PossibleBackupStorageRedundancyValues() []BackupStorageRedundancy { + return []BackupStorageRedundancy{Geo, Local, Zone} +} + // BlobAuditingPolicyState enumerates the values for blob auditing policy state. type BlobAuditingPolicyState string @@ -272,6 +289,23 @@ func PossibleCreateModeValues() []CreateMode { return []CreateMode{CreateModeCopy, CreateModeDefault, CreateModeOnlineSecondary, CreateModePointInTimeRestore, CreateModeRecovery, CreateModeRestore, CreateModeRestoreExternalBackup, CreateModeRestoreExternalBackupSecondary, CreateModeRestoreLongTermRetentionBackup, CreateModeSecondary} } +// CurrentBackupStorageRedundancy enumerates the values for current backup storage redundancy. +type CurrentBackupStorageRedundancy string + +const ( + // CurrentBackupStorageRedundancyGeo ... + CurrentBackupStorageRedundancyGeo CurrentBackupStorageRedundancy = "Geo" + // CurrentBackupStorageRedundancyLocal ... + CurrentBackupStorageRedundancyLocal CurrentBackupStorageRedundancy = "Local" + // CurrentBackupStorageRedundancyZone ... + CurrentBackupStorageRedundancyZone CurrentBackupStorageRedundancy = "Zone" +) + +// PossibleCurrentBackupStorageRedundancyValues returns an array of possible values for the CurrentBackupStorageRedundancy const type. +func PossibleCurrentBackupStorageRedundancyValues() []CurrentBackupStorageRedundancy { + return []CurrentBackupStorageRedundancy{CurrentBackupStorageRedundancyGeo, CurrentBackupStorageRedundancyLocal, CurrentBackupStorageRedundancyZone} +} + // DatabaseLicenseType enumerates the values for database license type. type DatabaseLicenseType string @@ -302,106 +336,21 @@ func PossibleDatabaseReadScaleValues() []DatabaseReadScale { return []DatabaseReadScale{DatabaseReadScaleDisabled, DatabaseReadScaleEnabled} } -// DatabaseState1 enumerates the values for database state 1. -type DatabaseState1 string +// DatabaseState enumerates the values for database state. +type DatabaseState string const ( // All ... - All DatabaseState1 = "All" + All DatabaseState = "All" // Deleted ... - Deleted DatabaseState1 = "Deleted" + Deleted DatabaseState = "Deleted" // Live ... - Live DatabaseState1 = "Live" -) - -// PossibleDatabaseState1Values returns an array of possible values for the DatabaseState1 const type. -func PossibleDatabaseState1Values() []DatabaseState1 { - return []DatabaseState1{All, Deleted, Live} -} - -// DatabaseState2 enumerates the values for database state 2. -type DatabaseState2 string - -const ( - // DatabaseState2All ... - DatabaseState2All DatabaseState2 = "All" - // DatabaseState2Deleted ... - DatabaseState2Deleted DatabaseState2 = "Deleted" - // DatabaseState2Live ... - DatabaseState2Live DatabaseState2 = "Live" -) - -// PossibleDatabaseState2Values returns an array of possible values for the DatabaseState2 const type. -func PossibleDatabaseState2Values() []DatabaseState2 { - return []DatabaseState2{DatabaseState2All, DatabaseState2Deleted, DatabaseState2Live} -} - -// DatabaseState3 enumerates the values for database state 3. -type DatabaseState3 string - -const ( - // DatabaseState3All ... - DatabaseState3All DatabaseState3 = "All" - // DatabaseState3Deleted ... - DatabaseState3Deleted DatabaseState3 = "Deleted" - // DatabaseState3Live ... - DatabaseState3Live DatabaseState3 = "Live" -) - -// PossibleDatabaseState3Values returns an array of possible values for the DatabaseState3 const type. -func PossibleDatabaseState3Values() []DatabaseState3 { - return []DatabaseState3{DatabaseState3All, DatabaseState3Deleted, DatabaseState3Live} -} - -// DatabaseState4 enumerates the values for database state 4. -type DatabaseState4 string - -const ( - // DatabaseState4All ... - DatabaseState4All DatabaseState4 = "All" - // DatabaseState4Deleted ... - DatabaseState4Deleted DatabaseState4 = "Deleted" - // DatabaseState4Live ... - DatabaseState4Live DatabaseState4 = "Live" + Live DatabaseState = "Live" ) -// PossibleDatabaseState4Values returns an array of possible values for the DatabaseState4 const type. -func PossibleDatabaseState4Values() []DatabaseState4 { - return []DatabaseState4{DatabaseState4All, DatabaseState4Deleted, DatabaseState4Live} -} - -// DatabaseState5 enumerates the values for database state 5. -type DatabaseState5 string - -const ( - // DatabaseState5All ... - DatabaseState5All DatabaseState5 = "All" - // DatabaseState5Deleted ... - DatabaseState5Deleted DatabaseState5 = "Deleted" - // DatabaseState5Live ... - DatabaseState5Live DatabaseState5 = "Live" -) - -// PossibleDatabaseState5Values returns an array of possible values for the DatabaseState5 const type. -func PossibleDatabaseState5Values() []DatabaseState5 { - return []DatabaseState5{DatabaseState5All, DatabaseState5Deleted, DatabaseState5Live} -} - -// DatabaseState6 enumerates the values for database state 6. -type DatabaseState6 string - -const ( - // DatabaseState6All ... - DatabaseState6All DatabaseState6 = "All" - // DatabaseState6Deleted ... - DatabaseState6Deleted DatabaseState6 = "Deleted" - // DatabaseState6Live ... - DatabaseState6Live DatabaseState6 = "Live" -) - -// PossibleDatabaseState6Values returns an array of possible values for the DatabaseState6 const type. -func PossibleDatabaseState6Values() []DatabaseState6 { - return []DatabaseState6{DatabaseState6All, DatabaseState6Deleted, DatabaseState6Live} +// PossibleDatabaseStateValues returns an array of possible values for the DatabaseState const type. +func PossibleDatabaseStateValues() []DatabaseState { + return []DatabaseState{All, Deleted, Live} } // DatabaseStatus enumerates the values for database status. @@ -601,13 +550,15 @@ const ( None IdentityType = "None" // SystemAssigned ... SystemAssigned IdentityType = "SystemAssigned" + // SystemAssignedUserAssigned ... + SystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" // UserAssigned ... UserAssigned IdentityType = "UserAssigned" ) // PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. func PossibleIdentityTypeValues() []IdentityType { - return []IdentityType{None, SystemAssigned, UserAssigned} + return []IdentityType{None, SystemAssigned, SystemAssignedUserAssigned, UserAssigned} } // InstanceFailoverGroupReplicationRole enumerates the values for instance failover group replication role. @@ -803,23 +754,6 @@ func PossibleLogSizeUnitValues() []LogSizeUnit { return []LogSizeUnit{Gigabytes, Megabytes, Percent, Petabytes, Terabytes} } -// LongTermRetentionDatabaseState enumerates the values for long term retention database state. -type LongTermRetentionDatabaseState string - -const ( - // LongTermRetentionDatabaseStateAll ... - LongTermRetentionDatabaseStateAll LongTermRetentionDatabaseState = "All" - // LongTermRetentionDatabaseStateDeleted ... - LongTermRetentionDatabaseStateDeleted LongTermRetentionDatabaseState = "Deleted" - // LongTermRetentionDatabaseStateLive ... - LongTermRetentionDatabaseStateLive LongTermRetentionDatabaseState = "Live" -) - -// PossibleLongTermRetentionDatabaseStateValues returns an array of possible values for the LongTermRetentionDatabaseState const type. -func PossibleLongTermRetentionDatabaseStateValues() []LongTermRetentionDatabaseState { - return []LongTermRetentionDatabaseState{LongTermRetentionDatabaseStateAll, LongTermRetentionDatabaseStateDeleted, LongTermRetentionDatabaseStateLive} -} - // ManagedDatabaseCreateMode enumerates the values for managed database create mode. type ManagedDatabaseCreateMode string @@ -1329,6 +1263,23 @@ func PossibleReplicaTypeValues() []ReplicaType { return []ReplicaType{ReplicaTypePrimary, ReplicaTypeReadableSecondary} } +// RequestedBackupStorageRedundancy enumerates the values for requested backup storage redundancy. +type RequestedBackupStorageRedundancy string + +const ( + // RequestedBackupStorageRedundancyGeo ... + RequestedBackupStorageRedundancyGeo RequestedBackupStorageRedundancy = "Geo" + // RequestedBackupStorageRedundancyLocal ... + RequestedBackupStorageRedundancyLocal RequestedBackupStorageRedundancy = "Local" + // RequestedBackupStorageRedundancyZone ... + RequestedBackupStorageRedundancyZone RequestedBackupStorageRedundancy = "Zone" +) + +// PossibleRequestedBackupStorageRedundancyValues returns an array of possible values for the RequestedBackupStorageRedundancy const type. +func PossibleRequestedBackupStorageRedundancyValues() []RequestedBackupStorageRedundancy { + return []RequestedBackupStorageRedundancy{RequestedBackupStorageRedundancyGeo, RequestedBackupStorageRedundancyLocal, RequestedBackupStorageRedundancyZone} +} + // RestorePointType enumerates the values for restore point type. type RestorePointType string @@ -1365,15 +1316,15 @@ func PossibleSampleNameValues() []SampleName { type SecondaryType string const ( - // Geo ... - Geo SecondaryType = "Geo" - // Named ... - Named SecondaryType = "Named" + // SecondaryTypeGeo ... + SecondaryTypeGeo SecondaryType = "Geo" + // SecondaryTypeNamed ... + SecondaryTypeNamed SecondaryType = "Named" ) // PossibleSecondaryTypeValues returns an array of possible values for the SecondaryType const type. func PossibleSecondaryTypeValues() []SecondaryType { - return []SecondaryType{Geo, Named} + return []SecondaryType{SecondaryTypeGeo, SecondaryTypeNamed} } // SecurityAlertPolicyEmailAccountAdmins enumerates the values for security alert policy email account admins. @@ -1870,6 +1821,23 @@ func PossibleSyncMemberStateValues() []SyncMemberState { return []SyncMemberState{DeProvisioned, DeProvisionFailed, DeProvisioning, DisabledBackupRestore, DisabledTombstoneCleanup, Provisioned, ProvisionFailed, Provisioning, ReprovisionFailed, Reprovisioning, SyncCancelled, SyncCancelling, SyncFailed, SyncInProgress, SyncSucceeded, SyncSucceededWithWarnings, UnProvisioned, UnReprovisioned} } +// TargetBackupStorageRedundancy enumerates the values for target backup storage redundancy. +type TargetBackupStorageRedundancy string + +const ( + // TargetBackupStorageRedundancyGeo ... + TargetBackupStorageRedundancyGeo TargetBackupStorageRedundancy = "Geo" + // TargetBackupStorageRedundancyLocal ... + TargetBackupStorageRedundancyLocal TargetBackupStorageRedundancy = "Local" + // TargetBackupStorageRedundancyZone ... + TargetBackupStorageRedundancyZone TargetBackupStorageRedundancy = "Zone" +) + +// PossibleTargetBackupStorageRedundancyValues returns an array of possible values for the TargetBackupStorageRedundancy const type. +func PossibleTargetBackupStorageRedundancyValues() []TargetBackupStorageRedundancy { + return []TargetBackupStorageRedundancy{TargetBackupStorageRedundancyGeo, TargetBackupStorageRedundancyLocal, TargetBackupStorageRedundancyZone} +} + // TransparentDataEncryptionActivityStatus enumerates the values for transparent data encryption activity // status. type TransparentDataEncryptionActivityStatus string diff --git a/services/preview/sql/mgmt/v4.0/sql/longtermretentionbackups.go b/services/preview/sql/mgmt/v4.0/sql/longtermretentionbackups.go index c2b40d332dd1..99ca55b9bef1 100644 --- a/services/preview/sql/mgmt/v4.0/sql/longtermretentionbackups.go +++ b/services/preview/sql/mgmt/v4.0/sql/longtermretentionbackups.go @@ -33,6 +33,181 @@ func NewLongTermRetentionBackupsClientWithBaseURI(baseURI string, subscriptionID return LongTermRetentionBackupsClient{NewWithBaseURI(baseURI, subscriptionID)} } +// Copy copy an existing long term retention backup. +// Parameters: +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the parameters needed for long term retention copy request +func (client LongTermRetentionBackupsClient) Copy(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (result LongTermRetentionBackupsCopyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Copy") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CopyPreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Copy", nil, "Failure preparing request") + return + } + + result, err = client.CopySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Copy", result.Response(), "Failure sending request") + return + } + + return +} + +// CopyPreparer prepares the Copy request. +func (client LongTermRetentionBackupsClient) CopyPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CopySender sends the Copy request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) CopySender(req *http.Request) (future LongTermRetentionBackupsCopyFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CopyResponder handles the response to the Copy request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) CopyResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CopyByResourceGroup copy an existing long term retention backup to a different server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the parameters needed for long term retention copy request +func (client LongTermRetentionBackupsClient) CopyByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (result LongTermRetentionBackupsCopyByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.CopyByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CopyByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "CopyByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.CopyByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "CopyByResourceGroup", result.Response(), "Failure sending request") + return + } + + return +} + +// CopyByResourceGroupPreparer prepares the CopyByResourceGroup request. +func (client LongTermRetentionBackupsClient) CopyByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CopyByResourceGroupSender sends the CopyByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) CopyByResourceGroupSender(req *http.Request) (future LongTermRetentionBackupsCopyByResourceGroupFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CopyByResourceGroupResponder handles the response to the CopyByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) CopyByResourceGroupResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // Delete deletes a long term retention backup. // Parameters: // locationName - the location of the database @@ -75,7 +250,7 @@ func (client LongTermRetentionBackupsClient) DeletePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -160,7 +335,7 @@ func (client LongTermRetentionBackupsClient) DeleteByResourceGroupPreparer(ctx c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -249,7 +424,7 @@ func (client LongTermRetentionBackupsClient) GetPreparer(ctx context.Context, lo "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -332,7 +507,7 @@ func (client LongTermRetentionBackupsClient) GetByResourceGroupPreparer(ctx cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -370,7 +545,7 @@ func (client LongTermRetentionBackupsClient) GetByResourceGroupResponder(resp *h // longTermRetentionDatabaseName - the name of the database // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionBackupsClient) ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionBackupsClient) ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByDatabase") defer func() { @@ -409,7 +584,7 @@ func (client LongTermRetentionBackupsClient) ListByDatabase(ctx context.Context, } // ListByDatabasePreparer prepares the ListByDatabase request. -func (client LongTermRetentionBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { +func (client LongTermRetentionBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), @@ -417,7 +592,7 @@ func (client LongTermRetentionBackupsClient) ListByDatabasePreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -476,7 +651,7 @@ func (client LongTermRetentionBackupsClient) listByDatabaseNextResults(ctx conte } // ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByDatabase") defer func() { @@ -496,7 +671,7 @@ func (client LongTermRetentionBackupsClient) ListByDatabaseComplete(ctx context. // locationName - the location of the database // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByLocation") defer func() { @@ -535,13 +710,13 @@ func (client LongTermRetentionBackupsClient) ListByLocation(ctx context.Context, } // ListByLocationPreparer prepares the ListByLocation request. -func (client LongTermRetentionBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { +func (client LongTermRetentionBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -600,7 +775,7 @@ func (client LongTermRetentionBackupsClient) listByLocationNextResults(ctx conte } // ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByLocation") defer func() { @@ -624,7 +799,7 @@ func (client LongTermRetentionBackupsClient) ListByLocationComplete(ctx context. // longTermRetentionDatabaseName - the name of the database // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupDatabase") defer func() { @@ -663,7 +838,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabase(ctx con } // ListByResourceGroupDatabasePreparer prepares the ListByResourceGroupDatabase request. -func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), @@ -672,7 +847,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabasePreparer "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -731,7 +906,7 @@ func (client LongTermRetentionBackupsClient) listByResourceGroupDatabaseNextResu } // ListByResourceGroupDatabaseComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupDatabase") defer func() { @@ -753,7 +928,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseComplete // locationName - the location of the database // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupLocation") defer func() { @@ -792,14 +967,14 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupLocation(ctx con } // ListByResourceGroupLocationPreparer prepares the ListByResourceGroupLocation request. -func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -858,7 +1033,7 @@ func (client LongTermRetentionBackupsClient) listByResourceGroupLocationNextResu } // ListByResourceGroupLocationComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupLocation") defer func() { @@ -881,7 +1056,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationComplete // longTermRetentionServerName - the name of the server // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionBackupsClient) ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupServer") defer func() { @@ -920,7 +1095,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupServer(ctx conte } // ListByResourceGroupServerPreparer prepares the ListByResourceGroupServer request. -func (client LongTermRetentionBackupsClient) ListByResourceGroupServerPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), @@ -928,7 +1103,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupServerPreparer(c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -987,7 +1162,7 @@ func (client LongTermRetentionBackupsClient) listByResourceGroupServerNextResult } // ListByResourceGroupServerComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionBackupsClient) ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupServer") defer func() { @@ -1008,7 +1183,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupServerComplete(c // longTermRetentionServerName - the name of the server // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionBackupsClient) ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionBackupsClient) ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByServer") defer func() { @@ -1047,14 +1222,14 @@ func (client LongTermRetentionBackupsClient) ListByServer(ctx context.Context, l } // ListByServerPreparer prepares the ListByServer request. -func (client LongTermRetentionBackupsClient) ListByServerPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (*http.Request, error) { +func (client LongTermRetentionBackupsClient) ListByServerPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-03-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1113,7 +1288,7 @@ func (client LongTermRetentionBackupsClient) listByServerNextResults(ctx context } // ListByServerComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionBackupsClient) ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState LongTermRetentionDatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionBackupsClient) ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByServer") defer func() { @@ -1127,3 +1302,178 @@ func (client LongTermRetentionBackupsClient) ListByServerComplete(ctx context.Co result.page, err = client.ListByServer(ctx, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) return } + +// Update updates an existing long term retention backup. +// Parameters: +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the requested backup resource state +func (client LongTermRetentionBackupsClient) Update(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (result LongTermRetentionBackupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LongTermRetentionBackupsClient) UpdatePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", 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 LongTermRetentionBackupsClient) UpdateSender(req *http.Request) (future LongTermRetentionBackupsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) UpdateResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateByResourceGroup updates an existing long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the requested backup resource state +func (client LongTermRetentionBackupsClient) UpdateByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (result LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.UpdateByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "UpdateByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.UpdateByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "UpdateByResourceGroup", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdateByResourceGroupPreparer prepares the UpdateByResourceGroup request. +func (client LongTermRetentionBackupsClient) UpdateByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateByResourceGroupSender sends the UpdateByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) UpdateByResourceGroupSender(req *http.Request) (future LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateByResourceGroupResponder handles the response to the UpdateByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) UpdateByResourceGroupResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v4.0/sql/longtermretentionmanagedinstancebackups.go b/services/preview/sql/mgmt/v4.0/sql/longtermretentionmanagedinstancebackups.go index a0b0712c782d..dcca4055b809 100644 --- a/services/preview/sql/mgmt/v4.0/sql/longtermretentionmanagedinstancebackups.go +++ b/services/preview/sql/mgmt/v4.0/sql/longtermretentionmanagedinstancebackups.go @@ -371,7 +371,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupRe // databaseName - the name of the managed database. // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState1) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByDatabase") defer func() { @@ -410,7 +410,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabase(ctx c } // ListByDatabasePreparer prepares the ListByDatabase request. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState1) (*http.Request, error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "locationName": autorest.Encode("path", locationName), @@ -477,7 +477,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) listByDatabaseNextRe } // ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState1) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByDatabase") defer func() { @@ -498,7 +498,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseComple // managedInstanceName - the name of the managed instance. // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState2) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByInstance") defer func() { @@ -537,7 +537,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstance(ctx c } // ListByInstancePreparer prepares the ListByInstance request. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstancePreparer(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState2) (*http.Request, error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstancePreparer(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "managedInstanceName": autorest.Encode("path", managedInstanceName), @@ -603,7 +603,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) listByInstanceNextRe } // ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState2) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByInstance") defer func() { @@ -623,7 +623,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceComple // locationName - the location of the database. // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState3) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByLocation") defer func() { @@ -662,7 +662,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocation(ctx c } // ListByLocationPreparer prepares the ListByLocation request. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState3) (*http.Request, error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), @@ -727,7 +727,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) listByLocationNextRe } // ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState3) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByLocation") defer func() { @@ -751,7 +751,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationComple // databaseName - the name of the managed database. // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState4) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase") defer func() { @@ -790,7 +790,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupD } // ListByResourceGroupDatabasePreparer prepares the ListByResourceGroupDatabase request. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState4) (*http.Request, error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "locationName": autorest.Encode("path", locationName), @@ -858,7 +858,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupD } // ListByResourceGroupDatabaseComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState4) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase") defer func() { @@ -881,7 +881,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupD // managedInstanceName - the name of the managed instance. // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState5) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance") defer func() { @@ -920,7 +920,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupI } // ListByResourceGroupInstancePreparer prepares the ListByResourceGroupInstance request. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstancePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState5) (*http.Request, error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstancePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "managedInstanceName": autorest.Encode("path", managedInstanceName), @@ -987,7 +987,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupI } // ListByResourceGroupInstanceComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState5) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance") defer func() { @@ -1009,7 +1009,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupI // locationName - the location of the database. // onlyLatestPerDatabase - whether or not to only get the latest backup for each database. // databaseState - whether to query against just live databases, just deleted databases, or all databases. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState6) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation") defer func() { @@ -1048,7 +1048,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupL } // ListByResourceGroupLocationPreparer prepares the ListByResourceGroupLocation request. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState6) (*http.Request, error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { pathParameters := map[string]interface{}{ "locationName": autorest.Encode("path", locationName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -1114,7 +1114,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupL } // ListByResourceGroupLocationComplete enumerates all values, automatically crossing page boundaries as required. -func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState6) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation") defer func() { diff --git a/services/preview/sql/mgmt/v4.0/sql/longtermretentionpolicies.go b/services/preview/sql/mgmt/v4.0/sql/longtermretentionpolicies.go new file mode 100644 index 000000000000..ebbcb1d3fac2 --- /dev/null +++ b/services/preview/sql/mgmt/v4.0/sql/longtermretentionpolicies.go @@ -0,0 +1,321 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// LongTermRetentionPoliciesClient 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 LongTermRetentionPoliciesClient struct { + BaseClient +} + +// NewLongTermRetentionPoliciesClient creates an instance of the LongTermRetentionPoliciesClient client. +func NewLongTermRetentionPoliciesClient(subscriptionID string) LongTermRetentionPoliciesClient { + return NewLongTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLongTermRetentionPoliciesClientWithBaseURI creates an instance of the LongTermRetentionPoliciesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewLongTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) LongTermRetentionPoliciesClient { + return LongTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets a database's long term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the long term retention policy info. +func (client LongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LongTermRetentionPolicy) (result LongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LongTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LongTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", 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 LongTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future LongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LongTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result LongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's long term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client LongTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LongTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "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.LongTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LongTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-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}/backupLongTermRetentionPolicies/{policyName}", 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 LongTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LongTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result LongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's long term retention policy. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client LongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LongTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.ltrplr.Response.Response != nil { + sc = result.ltrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ltrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ltrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ltrplr.hasNextLink() && result.ltrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LongTermRetentionPoliciesClient) ListByDatabasePreparer(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 = "2020-11-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}/backupLongTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result LongTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults LongTermRetentionPolicyListResult) (result LongTermRetentionPolicyListResult, err error) { + req, err := lastResults.longTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LongTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v4.0/sql/models.go b/services/preview/sql/mgmt/v4.0/sql/models.go index 22e205ad101b..c02c4b9a43fe 100644 --- a/services/preview/sql/mgmt/v4.0/sql/models.go +++ b/services/preview/sql/mgmt/v4.0/sql/models.go @@ -477,122 +477,6 @@ type AzureADOnlyAuthProperties struct { AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` } -// BackupLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type BackupLongTermRetentionPoliciesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(BackupLongTermRetentionPoliciesClient) (BackupLongTermRetentionPolicy, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *BackupLongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for BackupLongTermRetentionPoliciesCreateOrUpdateFuture.Result. -func (future *BackupLongTermRetentionPoliciesCreateOrUpdateFuture) result(client BackupLongTermRetentionPoliciesClient) (bltrp BackupLongTermRetentionPolicy, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - bltrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if bltrp.Response.Response, err = future.GetResult(sender); err == nil && bltrp.Response.Response.StatusCode != http.StatusNoContent { - bltrp, err = client.CreateOrUpdateResponder(bltrp.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", bltrp.Response.Response, "Failure responding to request") - } - } - return -} - -// BackupLongTermRetentionPolicy a long term retention policy. -type BackupLongTermRetentionPolicy struct { - autorest.Response `json:"-"` - // LongTermRetentionPolicyProperties - Resource properties. - *LongTermRetentionPolicyProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for BackupLongTermRetentionPolicy. -func (bltrp BackupLongTermRetentionPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if bltrp.LongTermRetentionPolicyProperties != nil { - objectMap["properties"] = bltrp.LongTermRetentionPolicyProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for BackupLongTermRetentionPolicy struct. -func (bltrp *BackupLongTermRetentionPolicy) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var longTermRetentionPolicyProperties LongTermRetentionPolicyProperties - err = json.Unmarshal(*v, &longTermRetentionPolicyProperties) - if err != nil { - return err - } - bltrp.LongTermRetentionPolicyProperties = &longTermRetentionPolicyProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - bltrp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - bltrp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - bltrp.Type = &typeVar - } - } - } - - return nil -} - // BackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the // results of a long-running operation. type BackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { @@ -968,6 +852,63 @@ type CompleteDatabaseRestoreDefinition struct { LastBackupName *string `json:"lastBackupName,omitempty"` } +// CopyLongTermRetentionBackupParameters contains the information necessary to perform long term retention +// backup copy operation. +type CopyLongTermRetentionBackupParameters struct { + // CopyLongTermRetentionBackupParametersProperties - Resource properties. + *CopyLongTermRetentionBackupParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CopyLongTermRetentionBackupParameters. +func (cltrbp CopyLongTermRetentionBackupParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cltrbp.CopyLongTermRetentionBackupParametersProperties != nil { + objectMap["properties"] = cltrbp.CopyLongTermRetentionBackupParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CopyLongTermRetentionBackupParameters struct. +func (cltrbp *CopyLongTermRetentionBackupParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var copyLongTermRetentionBackupParametersProperties CopyLongTermRetentionBackupParametersProperties + err = json.Unmarshal(*v, ©LongTermRetentionBackupParametersProperties) + if err != nil { + return err + } + cltrbp.CopyLongTermRetentionBackupParametersProperties = ©LongTermRetentionBackupParametersProperties + } + } + } + + return nil +} + +// CopyLongTermRetentionBackupParametersProperties contains the properties to perform long term retention +// backup copy operation. +type CopyLongTermRetentionBackupParametersProperties struct { + // TargetSubscriptionID - The subscription that owns the target server + TargetSubscriptionID *string `json:"targetSubscriptionId,omitempty"` + // TargetResourceGroup - The resource group that owns the target server + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` + // TargetServerResourceID - The resource Id of the target server that owns the database + TargetServerResourceID *string `json:"targetServerResourceId,omitempty"` + // TargetServerFullyQualifiedDomainName - The fully qualified domain name of the target server + TargetServerFullyQualifiedDomainName *string `json:"targetServerFullyQualifiedDomainName,omitempty"` + // TargetDatabaseName - The name of the database owns the copied backup. + TargetDatabaseName *string `json:"targetDatabaseName,omitempty"` + // TargetBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'TargetBackupStorageRedundancyGeo', 'TargetBackupStorageRedundancyLocal', 'TargetBackupStorageRedundancyZone' + TargetBackupStorageRedundancy TargetBackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` +} + // CreateDatabaseRestorePointDefinition contains the information necessary to perform a create database // restore point operation. type CreateDatabaseRestorePointDefinition struct { @@ -1514,6 +1455,9 @@ type DatabaseBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -2071,14 +2015,16 @@ type DatabaseProperties struct { ReadScale DatabaseReadScale `json:"readScale,omitempty"` // HighAvailabilityReplicaCount - The number of secondary replicas associated with the database that are used to provide high availability. HighAvailabilityReplicaCount *int32 `json:"highAvailabilityReplicaCount,omitempty"` - // SecondaryType - The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: 'Geo', 'Named' + // SecondaryType - The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: 'SecondaryTypeGeo', 'SecondaryTypeNamed' SecondaryType SecondaryType `json:"secondaryType,omitempty"` // CurrentSku - READ-ONLY; The name and tier of the SKU. CurrentSku *Sku `json:"currentSku,omitempty"` // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` - // StorageAccountType - The storage account type used to store backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' - StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` + // CurrentBackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'CurrentBackupStorageRedundancyGeo', 'CurrentBackupStorageRedundancyLocal', 'CurrentBackupStorageRedundancyZone' + CurrentBackupStorageRedundancy CurrentBackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage account type to be used to store backups for this database. Possible values include: 'RequestedBackupStorageRedundancyGeo', 'RequestedBackupStorageRedundancyLocal', 'RequestedBackupStorageRedundancyZone' + RequestedBackupStorageRedundancy RequestedBackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` // MinCapacity - Minimal capacity that database will always have allocated, if not paused MinCapacity *float64 `json:"minCapacity,omitempty"` // PausedDate - READ-ONLY; The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. @@ -2149,8 +2095,8 @@ func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { if dp.AutoPauseDelay != nil { objectMap["autoPauseDelay"] = dp.AutoPauseDelay } - if dp.StorageAccountType != "" { - objectMap["storageAccountType"] = dp.StorageAccountType + if dp.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = dp.RequestedBackupStorageRedundancy } if dp.MinCapacity != nil { objectMap["minCapacity"] = dp.MinCapacity @@ -5394,6 +5340,9 @@ type ExtendedDatabaseBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -5773,6 +5722,9 @@ type ExtendedServerBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -10155,24 +10107,753 @@ type LongTermRetentionBackupListResult struct { NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for LongTermRetentionBackupListResult. -func (ltrblr LongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LongTermRetentionBackupListResult. +func (ltrblr LongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupListResultIterator provides access to a complete listing of +// LongTermRetentionBackup values. +type LongTermRetentionBackupListResultIterator struct { + i int + page LongTermRetentionBackupListResultPage +} + +// NextWithContext 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 *LongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LongTermRetentionBackupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LongTermRetentionBackupListResultIterator) 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 LongTermRetentionBackupListResultIterator) Response() LongTermRetentionBackupListResult { + 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 LongTermRetentionBackupListResultIterator) Value() LongTermRetentionBackup { + if !iter.page.NotDone() { + return LongTermRetentionBackup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LongTermRetentionBackupListResultIterator type. +func NewLongTermRetentionBackupListResultIterator(page LongTermRetentionBackupListResultPage) LongTermRetentionBackupListResultIterator { + return LongTermRetentionBackupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ltrblr LongTermRetentionBackupListResult) IsEmpty() bool { + return ltrblr.Value == nil || len(*ltrblr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ltrblr LongTermRetentionBackupListResult) hasNextLink() bool { + return ltrblr.NextLink != nil && len(*ltrblr.NextLink) != 0 +} + +// longTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ltrblr LongTermRetentionBackupListResult) longTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrblr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ltrblr.NextLink))) +} + +// LongTermRetentionBackupListResultPage contains a page of LongTermRetentionBackup values. +type LongTermRetentionBackupListResultPage struct { + fn func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error) + ltrblr LongTermRetentionBackupListResult +} + +// NextWithContext 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 *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ltrblr) + if err != nil { + return err + } + page.ltrblr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *LongTermRetentionBackupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LongTermRetentionBackupListResultPage) NotDone() bool { + return !page.ltrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LongTermRetentionBackupListResultPage) Response() LongTermRetentionBackupListResult { + return page.ltrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LongTermRetentionBackupListResultPage) Values() []LongTermRetentionBackup { + if page.ltrblr.IsEmpty() { + return nil + } + return *page.ltrblr.Value +} + +// Creates a new instance of the LongTermRetentionBackupListResultPage type. +func NewLongTermRetentionBackupListResultPage(cur LongTermRetentionBackupListResult, getNextPage func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error)) LongTermRetentionBackupListResultPage { + return LongTermRetentionBackupListResultPage{ + fn: getNextPage, + ltrblr: cur, + } +} + +// LongTermRetentionBackupOperationResult a LongTermRetentionBackup operation result resource. +type LongTermRetentionBackupOperationResult struct { + autorest.Response `json:"-"` + // LongTermRetentionOperationResultProperties - Resource properties. + *LongTermRetentionOperationResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupOperationResult. +func (ltrbor LongTermRetentionBackupOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrbor.LongTermRetentionOperationResultProperties != nil { + objectMap["properties"] = ltrbor.LongTermRetentionOperationResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackupOperationResult struct. +func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var longTermRetentionOperationResultProperties LongTermRetentionOperationResultProperties + err = json.Unmarshal(*v, &longTermRetentionOperationResultProperties) + if err != nil { + return err + } + ltrbor.LongTermRetentionOperationResultProperties = &longTermRetentionOperationResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ltrbor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ltrbor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ltrbor.Type = &typeVar + } + } + } + + return nil +} + +// LongTermRetentionBackupProperties properties of a long term retention backup +type LongTermRetentionBackupProperties struct { + // ServerName - READ-ONLY; The server name that the backup database belong to. + ServerName *string `json:"serverName,omitempty"` + // ServerCreateTime - READ-ONLY; The create time of the server. + ServerCreateTime *date.Time `json:"serverCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'Geo', 'Local', 'Zone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage redundancy type of the backup. Possible values include: 'Geo', 'Local', 'Zone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupProperties. +func (ltrbp LongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrbp.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = ltrbp.RequestedBackupStorageRedundancy + } + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupsCopyByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsCopyByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsCopyByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyByResourceGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.CopyByResourceGroupResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionBackupsCopyFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsCopyFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsCopyFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsCopyFuture.Result. +func (future *LongTermRetentionBackupsCopyFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.CopyResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionBackupsDeleteByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsDeleteFuture.Result. +func (future *LongTermRetentionBackupsDeleteFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionBackupsUpdateByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsUpdateByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsUpdateByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateByResourceGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.UpdateByResourceGroupResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionBackupsUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsUpdateFuture.Result. +func (future *LongTermRetentionBackupsUpdateFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.UpdateResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionManagedInstanceBackupsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionOperationResultProperties contains the operation result properties for long term +// retention backup operation. +type LongTermRetentionOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // OperationType - READ-ONLY; Operation type. + OperationType *string `json:"operationType,omitempty"` + // FromBackupResourceID - READ-ONLY; Source backup resource id + FromBackupResourceID *string `json:"fromBackupResourceId,omitempty"` + // ToBackupResourceID - READ-ONLY; Target backup resource id + ToBackupResourceID *string `json:"toBackupResourceId,omitempty"` + // TargetBackupStorageRedundancy - READ-ONLY; The storage redundancy type of the copied backup. Possible values include: 'Geo', 'Local', 'Zone' + TargetBackupStorageRedundancy BackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` + // Status - READ-ONLY; Operation status + Status *string `json:"status,omitempty"` + // Message - READ-ONLY; Progress message + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionOperationResultProperties. +func (ltrorp LongTermRetentionOperationResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type LongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionPoliciesClient) (LongTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) result(client LongTermRetentionPoliciesClient) (ltrp LongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrp.Response.Response, err = future.GetResult(sender); err == nil && ltrp.Response.Response.StatusCode != http.StatusNoContent { + ltrp, err = client.CreateOrUpdateResponder(ltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", ltrp.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionPolicy a long term retention policy. +type LongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BaseLongTermRetentionPolicyProperties - Resource properties. + *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionPolicy. +func (ltrp LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrp.BaseLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = ltrp.BaseLongTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionPolicy struct. +func (ltrp *LongTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) + if err != nil { + return err + } + ltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ltrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ltrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ltrp.Type = &typeVar + } + } + } + + return nil +} + +// LongTermRetentionPolicyListResult a list of long term retention policies. +type LongTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LongTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionPolicyListResult. +func (ltrplr LongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// LongTermRetentionBackupListResultIterator provides access to a complete listing of -// LongTermRetentionBackup values. -type LongTermRetentionBackupListResultIterator struct { +// LongTermRetentionPolicyListResultIterator provides access to a complete listing of +// LongTermRetentionPolicy values. +type LongTermRetentionPolicyListResultIterator struct { i int - page LongTermRetentionBackupListResultPage + page LongTermRetentionPolicyListResultPage } // NextWithContext 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 *LongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *LongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -10197,67 +10878,67 @@ func (iter *LongTermRetentionBackupListResultIterator) NextWithContext(ctx conte // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *LongTermRetentionBackupListResultIterator) Next() error { +func (iter *LongTermRetentionPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter LongTermRetentionBackupListResultIterator) NotDone() bool { +func (iter LongTermRetentionPolicyListResultIterator) 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 LongTermRetentionBackupListResultIterator) Response() LongTermRetentionBackupListResult { +func (iter LongTermRetentionPolicyListResultIterator) Response() LongTermRetentionPolicyListResult { 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 LongTermRetentionBackupListResultIterator) Value() LongTermRetentionBackup { +func (iter LongTermRetentionPolicyListResultIterator) Value() LongTermRetentionPolicy { if !iter.page.NotDone() { - return LongTermRetentionBackup{} + return LongTermRetentionPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the LongTermRetentionBackupListResultIterator type. -func NewLongTermRetentionBackupListResultIterator(page LongTermRetentionBackupListResultPage) LongTermRetentionBackupListResultIterator { - return LongTermRetentionBackupListResultIterator{page: page} +// Creates a new instance of the LongTermRetentionPolicyListResultIterator type. +func NewLongTermRetentionPolicyListResultIterator(page LongTermRetentionPolicyListResultPage) LongTermRetentionPolicyListResultIterator { + return LongTermRetentionPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (ltrblr LongTermRetentionBackupListResult) IsEmpty() bool { - return ltrblr.Value == nil || len(*ltrblr.Value) == 0 +func (ltrplr LongTermRetentionPolicyListResult) IsEmpty() bool { + return ltrplr.Value == nil || len(*ltrplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (ltrblr LongTermRetentionBackupListResult) hasNextLink() bool { - return ltrblr.NextLink != nil && len(*ltrblr.NextLink) != 0 +func (ltrplr LongTermRetentionPolicyListResult) hasNextLink() bool { + return ltrplr.NextLink != nil && len(*ltrplr.NextLink) != 0 } -// longTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// longTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (ltrblr LongTermRetentionBackupListResult) longTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ltrblr.hasNextLink() { +func (ltrplr LongTermRetentionPolicyListResult) longTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(ltrblr.NextLink))) + autorest.WithBaseURL(to.String(ltrplr.NextLink))) } -// LongTermRetentionBackupListResultPage contains a page of LongTermRetentionBackup values. -type LongTermRetentionBackupListResultPage struct { - fn func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error) - ltrblr LongTermRetentionBackupListResult +// LongTermRetentionPolicyListResultPage contains a page of LongTermRetentionPolicy values. +type LongTermRetentionPolicyListResultPage struct { + fn func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error) + ltrplr LongTermRetentionPolicyListResult } // NextWithContext 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 *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *LongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -10267,11 +10948,11 @@ func (page *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.C }() } for { - next, err := page.fn(ctx, page.ltrblr) + next, err := page.fn(ctx, page.ltrplr) if err != nil { return err } - page.ltrblr = next + page.ltrplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -10282,216 +10963,34 @@ func (page *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.C // 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. // Deprecated: Use NextWithContext() instead. -func (page *LongTermRetentionBackupListResultPage) Next() error { +func (page *LongTermRetentionPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page LongTermRetentionBackupListResultPage) NotDone() bool { - return !page.ltrblr.IsEmpty() +func (page LongTermRetentionPolicyListResultPage) NotDone() bool { + return !page.ltrplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page LongTermRetentionBackupListResultPage) Response() LongTermRetentionBackupListResult { - return page.ltrblr +func (page LongTermRetentionPolicyListResultPage) Response() LongTermRetentionPolicyListResult { + return page.ltrplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page LongTermRetentionBackupListResultPage) Values() []LongTermRetentionBackup { - if page.ltrblr.IsEmpty() { +func (page LongTermRetentionPolicyListResultPage) Values() []LongTermRetentionPolicy { + if page.ltrplr.IsEmpty() { return nil } - return *page.ltrblr.Value + return *page.ltrplr.Value } -// Creates a new instance of the LongTermRetentionBackupListResultPage type. -func NewLongTermRetentionBackupListResultPage(cur LongTermRetentionBackupListResult, getNextPage func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error)) LongTermRetentionBackupListResultPage { - return LongTermRetentionBackupListResultPage{ +// Creates a new instance of the LongTermRetentionPolicyListResultPage type. +func NewLongTermRetentionPolicyListResultPage(cur LongTermRetentionPolicyListResult, getNextPage func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error)) LongTermRetentionPolicyListResultPage { + return LongTermRetentionPolicyListResultPage{ fn: getNextPage, - ltrblr: cur, - } -} - -// LongTermRetentionBackupProperties properties of a long term retention backup -type LongTermRetentionBackupProperties struct { - // ServerName - READ-ONLY; The server name that the backup database belong to. - ServerName *string `json:"serverName,omitempty"` - // ServerCreateTime - READ-ONLY; The create time of the server. - ServerCreateTime *date.Time `json:"serverCreateTime,omitempty"` - // DatabaseName - READ-ONLY; The name of the database the backup belong to - DatabaseName *string `json:"databaseName,omitempty"` - // DatabaseDeletionTime - READ-ONLY; The delete time of the database - DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` - // BackupTime - READ-ONLY; The time the backup was taken - BackupTime *date.Time `json:"backupTime,omitempty"` - // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. - BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` -} - -// MarshalJSON is the custom marshaler for LongTermRetentionBackupProperties. -func (ltrbp LongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// LongTermRetentionBackupsDeleteByResourceGroupFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type LongTermRetentionBackupsDeleteByResourceGroupFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for LongTermRetentionBackupsDeleteByResourceGroupFuture.Result. -func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteByResourceGroupFuture") - return - } - ar.Response = future.Response() - return -} - -// LongTermRetentionBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type LongTermRetentionBackupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for LongTermRetentionBackupsDeleteFuture.Result. -func (future *LongTermRetentionBackupsDeleteFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture.Result. -func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture") - return - } - ar.Response = future.Response() - return -} - -// LongTermRetentionManagedInstanceBackupsDeleteFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type LongTermRetentionManagedInstanceBackupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteFuture.Result. -func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteFuture") - return + ltrplr: cur, } - ar.Response = future.Response() - return -} - -// LongTermRetentionPolicyProperties properties of a long term retention policy -type LongTermRetentionPolicyProperties struct { - // WeeklyRetention - The weekly retention policy for an LTR backup in an ISO 8601 format. - WeeklyRetention *string `json:"weeklyRetention,omitempty"` - // MonthlyRetention - The monthly retention policy for an LTR backup in an ISO 8601 format. - MonthlyRetention *string `json:"monthlyRetention,omitempty"` - // YearlyRetention - The yearly retention policy for an LTR backup in an ISO 8601 format. - YearlyRetention *string `json:"yearlyRetention,omitempty"` - // WeekOfYear - The week of year to take the yearly backup in an ISO 8601 format. - WeekOfYear *int32 `json:"weekOfYear,omitempty"` } // MaintenanceConfigurationCapability the maintenance configuration capability @@ -17507,7 +18006,7 @@ func (r Resource) MarshalJSON() ([]byte, error) { type ResourceIdentity struct { // PrincipalID - READ-ONLY; The Azure Active Directory principal id. PrincipalID *uuid.UUID `json:"principalId,omitempty"` - // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'None', 'SystemAssigned', 'UserAssigned' + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned' Type IdentityType `json:"type,omitempty"` // TenantID - READ-ONLY; The Azure Active Directory tenant id. TenantID *uuid.UUID `json:"tenantId,omitempty"` @@ -19247,6 +19746,9 @@ type ServerBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -24535,26 +25037,20 @@ func (future *SyncMembersUpdateFuture) result(client SyncMembersClient) (sm Sync // SystemData metadata pertaining to creation and last modification of the resource. type SystemData struct { - // CreatedBy - READ-ONLY; A string identifier for the identity that created the resource. + // CreatedBy - The identity that created the resource. CreatedBy *string `json:"createdBy,omitempty"` - // CreatedByType - READ-ONLY; The type of identity that created the resource: . Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' CreatedByType CreatedByType `json:"createdByType,omitempty"` - // CreatedAt - READ-ONLY; The timestamp of resource creation (UTC). + // CreatedAt - The timestamp of resource creation (UTC). CreatedAt *date.Time `json:"createdAt,omitempty"` - // LastModifiedBy - READ-ONLY; A string identifier for the identity that last modified the resource. + // LastModifiedBy - The identity that last modified the resource. LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - // LastModifiedByType - READ-ONLY; The type of identity that last modified the resource: . Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` - // LastModifiedAt - READ-ONLY; The timestamp of last modification (UTC). + // LastModifiedAt - The timestamp of resource last modification (UTC) LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` } -// MarshalJSON is the custom marshaler for SystemData. -func (sd SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - // TdeCertificate a TDE certificate that can be uploaded into a server. type TdeCertificate struct { // TdeCertificateProperties - Resource properties. @@ -25092,6 +25588,53 @@ type UnlinkParameters struct { ForcedTermination *bool `json:"forcedTermination,omitempty"` } +// UpdateLongTermRetentionBackupParameters contains the information necessary to perform long term +// retention backup update operation. +type UpdateLongTermRetentionBackupParameters struct { + // UpdateLongTermRetentionBackupParametersProperties - Resource properties. + *UpdateLongTermRetentionBackupParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for UpdateLongTermRetentionBackupParameters. +func (ultrbp UpdateLongTermRetentionBackupParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ultrbp.UpdateLongTermRetentionBackupParametersProperties != nil { + objectMap["properties"] = ultrbp.UpdateLongTermRetentionBackupParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UpdateLongTermRetentionBackupParameters struct. +func (ultrbp *UpdateLongTermRetentionBackupParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var updateLongTermRetentionBackupParametersProperties UpdateLongTermRetentionBackupParametersProperties + err = json.Unmarshal(*v, &updateLongTermRetentionBackupParametersProperties) + if err != nil { + return err + } + ultrbp.UpdateLongTermRetentionBackupParametersProperties = &updateLongTermRetentionBackupParametersProperties + } + } + } + + return nil +} + +// UpdateLongTermRetentionBackupParametersProperties contains the properties to perform long term retention +// backup copy operation. +type UpdateLongTermRetentionBackupParametersProperties struct { + // RequestedBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'RequestedBackupStorageRedundancyGeo', 'RequestedBackupStorageRedundancyLocal', 'RequestedBackupStorageRedundancyZone' + RequestedBackupStorageRedundancy RequestedBackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` +} + // UpsertManagedServerOperationParameters ... type UpsertManagedServerOperationParameters struct { Family *string `json:"family,omitempty"` diff --git a/services/preview/sql/mgmt/v4.0/sql/privateendpointconnections.go b/services/preview/sql/mgmt/v4.0/sql/privateendpointconnections.go index d66b3e5f3f61..9fcd87b43a29 100644 --- a/services/preview/sql/mgmt/v4.0/sql/privateendpointconnections.go +++ b/services/preview/sql/mgmt/v4.0/sql/privateendpointconnections.go @@ -83,7 +83,7 @@ func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-06-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -166,7 +166,7 @@ func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-06-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -254,7 +254,7 @@ func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-06-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -336,7 +336,7 @@ func (client PrivateEndpointConnectionsClient) ListByServerPreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-06-01-preview" + const APIVersion = "2020-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v4.0/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/v4.0/sql/sqlapi/interfaces.go index 6775b55a1c3c..6b968f8fd195 100644 --- a/services/preview/sql/mgmt/v4.0/sql/sqlapi/interfaces.go +++ b/services/preview/sql/mgmt/v4.0/sql/sqlapi/interfaces.go @@ -471,37 +471,6 @@ type JobVersionsClientAPI interface { var _ JobVersionsClientAPI = (*sql.JobVersionsClient)(nil) -// LongTermRetentionBackupsClientAPI contains the set of methods on the LongTermRetentionBackupsClient type. -type LongTermRetentionBackupsClientAPI interface { - Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteFuture, err error) - DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) - Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) - GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) - ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.LongTermRetentionDatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) -} - -var _ LongTermRetentionBackupsClientAPI = (*sql.LongTermRetentionBackupsClient)(nil) - -// BackupLongTermRetentionPoliciesClientAPI contains the set of methods on the BackupLongTermRetentionPoliciesClient type. -type BackupLongTermRetentionPoliciesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupLongTermRetentionPolicy) (result sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupLongTermRetentionPolicy, err error) - ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupLongTermRetentionPolicy, err error) -} - -var _ BackupLongTermRetentionPoliciesClientAPI = (*sql.BackupLongTermRetentionPoliciesClient)(nil) - // ManagedBackupShortTermRetentionPoliciesClientAPI contains the set of methods on the ManagedBackupShortTermRetentionPoliciesClient type. type ManagedBackupShortTermRetentionPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) @@ -807,17 +776,6 @@ type UsagesClientAPI interface { var _ UsagesClientAPI = (*sql.UsagesClient)(nil) -// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. -type PrivateEndpointConnectionsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters sql.PrivateEndpointConnection) (result sql.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnectionsDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnection, err error) - ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultPage, err error) - ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultIterator, err error) -} - -var _ PrivateEndpointConnectionsClientAPI = (*sql.PrivateEndpointConnectionsClient)(nil) - // PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. type PrivateLinkResourcesClientAPI interface { Get(ctx context.Context, resourceGroupName string, serverName string, groupName string) (result sql.PrivateLinkResource, err error) @@ -856,18 +814,18 @@ type LongTermRetentionManagedInstanceBackupsClientAPI interface { DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) - ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState1) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState1) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState2) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState2) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState3) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState3) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState4) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState4) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState5) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState5) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState6) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState6) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) } var _ LongTermRetentionManagedInstanceBackupsClientAPI = (*sql.LongTermRetentionManagedInstanceBackupsClient)(nil) @@ -1053,3 +1011,50 @@ type ServerDevOpsAuditSettingsClientAPI interface { } var _ ServerDevOpsAuditSettingsClientAPI = (*sql.ServerDevOpsAuditSettingsClient)(nil) + +// LongTermRetentionBackupsClientAPI contains the set of methods on the LongTermRetentionBackupsClient type. +type LongTermRetentionBackupsClientAPI interface { + Copy(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyFuture, err error) + CopyByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyByResourceGroupFuture, err error) + Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + Update(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateFuture, err error) + UpdateByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) +} + +var _ LongTermRetentionBackupsClientAPI = (*sql.LongTermRetentionBackupsClient)(nil) + +// LongTermRetentionPoliciesClientAPI contains the set of methods on the LongTermRetentionPoliciesClient type. +type LongTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LongTermRetentionPolicy) (result sql.LongTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LongTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LongTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LongTermRetentionPolicyListResultIterator, err error) +} + +var _ LongTermRetentionPoliciesClientAPI = (*sql.LongTermRetentionPoliciesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters sql.PrivateEndpointConnection) (result sql.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnection, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*sql.PrivateEndpointConnectionsClient)(nil) diff --git a/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md b/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md index 52911e4cc5e4..cd1e9c8aad91 100644 --- a/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md +++ b/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md @@ -1,2 +1,623 @@ -# Change History +# Unreleased +## Breaking Changes + +### Removed Constants + +1. BackupStorageRedundancy1.BackupStorageRedundancy1Geo +1. BackupStorageRedundancy1.BackupStorageRedundancy1Local +1. BackupStorageRedundancy1.BackupStorageRedundancy1Zone +1. CurrentBackupStorageRedundancy.CurrentBackupStorageRedundancyGeo +1. CurrentBackupStorageRedundancy.CurrentBackupStorageRedundancyLocal +1. CurrentBackupStorageRedundancy.CurrentBackupStorageRedundancyZone +1. RequestedBackupStorageRedundancy.RequestedBackupStorageRedundancyGeo +1. RequestedBackupStorageRedundancy.RequestedBackupStorageRedundancyLocal +1. RequestedBackupStorageRedundancy.RequestedBackupStorageRedundancyZone +1. StorageAccountType1.StorageAccountType1GRS +1. StorageAccountType1.StorageAccountType1LRS +1. StorageAccountType1.StorageAccountType1ZRS +1. TargetBackupStorageRedundancy.TargetBackupStorageRedundancyGeo +1. TargetBackupStorageRedundancy.TargetBackupStorageRedundancyLocal +1. TargetBackupStorageRedundancy.TargetBackupStorageRedundancyZone +1. TransparentDataEncryptionActivityStatus.TransparentDataEncryptionActivityStatusDecrypting +1. TransparentDataEncryptionActivityStatus.TransparentDataEncryptionActivityStatusEncrypting +1. TransparentDataEncryptionStatus.TransparentDataEncryptionStatusDisabled +1. TransparentDataEncryptionStatus.TransparentDataEncryptionStatusEnabled + +### Removed Funcs + +1. *OperationsHealth.UnmarshalJSON([]byte) error +1. *OperationsHealthListResultIterator.Next() error +1. *OperationsHealthListResultIterator.NextWithContext(context.Context) error +1. *OperationsHealthListResultPage.Next() error +1. *OperationsHealthListResultPage.NextWithContext(context.Context) error +1. *ReplicationLinksUnlinkFuture.UnmarshalJSON([]byte) error +1. *TransparentDataEncryption.UnmarshalJSON([]byte) error +1. *TransparentDataEncryptionActivity.UnmarshalJSON([]byte) error +1. NewOperationsHealthClient(string) OperationsHealthClient +1. NewOperationsHealthClientWithBaseURI(string, string) OperationsHealthClient +1. NewOperationsHealthListResultIterator(OperationsHealthListResultPage) OperationsHealthListResultIterator +1. NewOperationsHealthListResultPage(OperationsHealthListResult, func(context.Context, OperationsHealthListResult) (OperationsHealthListResult, error)) OperationsHealthListResultPage +1. NewTransparentDataEncryptionActivitiesClient(string) TransparentDataEncryptionActivitiesClient +1. NewTransparentDataEncryptionActivitiesClientWithBaseURI(string, string) TransparentDataEncryptionActivitiesClient +1. OperationsHealth.MarshalJSON() ([]byte, error) +1. OperationsHealthClient.ListByLocation(context.Context, string) (OperationsHealthListResultPage, error) +1. OperationsHealthClient.ListByLocationComplete(context.Context, string) (OperationsHealthListResultIterator, error) +1. OperationsHealthClient.ListByLocationPreparer(context.Context, string) (*http.Request, error) +1. OperationsHealthClient.ListByLocationResponder(*http.Response) (OperationsHealthListResult, error) +1. OperationsHealthClient.ListByLocationSender(*http.Request) (*http.Response, error) +1. OperationsHealthListResult.IsEmpty() bool +1. OperationsHealthListResult.MarshalJSON() ([]byte, error) +1. OperationsHealthListResultIterator.NotDone() bool +1. OperationsHealthListResultIterator.Response() OperationsHealthListResult +1. OperationsHealthListResultIterator.Value() OperationsHealth +1. OperationsHealthListResultPage.NotDone() bool +1. OperationsHealthListResultPage.Response() OperationsHealthListResult +1. OperationsHealthListResultPage.Values() []OperationsHealth +1. OperationsHealthProperties.MarshalJSON() ([]byte, error) +1. PossibleBackupStorageRedundancy1Values() []BackupStorageRedundancy1 +1. PossibleCurrentBackupStorageRedundancyValues() []CurrentBackupStorageRedundancy +1. PossibleRequestedBackupStorageRedundancyValues() []RequestedBackupStorageRedundancy +1. PossibleStorageAccountType1Values() []StorageAccountType1 +1. PossibleTargetBackupStorageRedundancyValues() []TargetBackupStorageRedundancy +1. PossibleTransparentDataEncryptionActivityStatusValues() []TransparentDataEncryptionActivityStatus +1. PossibleTransparentDataEncryptionStatusValues() []TransparentDataEncryptionStatus +1. ReplicationLinksClient.Unlink(context.Context, string, string, string, string, UnlinkParameters) (ReplicationLinksUnlinkFuture, error) +1. ReplicationLinksClient.UnlinkPreparer(context.Context, string, string, string, string, UnlinkParameters) (*http.Request, error) +1. ReplicationLinksClient.UnlinkResponder(*http.Response) (autorest.Response, error) +1. ReplicationLinksClient.UnlinkSender(*http.Request) (ReplicationLinksUnlinkFuture, error) +1. ResourceIdentityWithUserAssignedIdentities.MarshalJSON() ([]byte, error) +1. TransparentDataEncryption.MarshalJSON() ([]byte, error) +1. TransparentDataEncryptionActivitiesClient.ListByConfiguration(context.Context, string, string, string) (TransparentDataEncryptionActivityListResult, error) +1. TransparentDataEncryptionActivitiesClient.ListByConfigurationPreparer(context.Context, string, string, string) (*http.Request, error) +1. TransparentDataEncryptionActivitiesClient.ListByConfigurationResponder(*http.Response) (TransparentDataEncryptionActivityListResult, error) +1. TransparentDataEncryptionActivitiesClient.ListByConfigurationSender(*http.Request) (*http.Response, error) +1. TransparentDataEncryptionActivity.MarshalJSON() ([]byte, error) +1. TransparentDataEncryptionActivityProperties.MarshalJSON() ([]byte, error) + +### Struct Changes + +#### Removed Structs + +1. OperationsHealth +1. OperationsHealthClient +1. OperationsHealthListResult +1. OperationsHealthListResultIterator +1. OperationsHealthListResultPage +1. OperationsHealthProperties +1. ReplicationLinksUnlinkFuture +1. ResourceIdentityWithUserAssignedIdentities +1. TransparentDataEncryption +1. TransparentDataEncryptionActivitiesClient +1. TransparentDataEncryptionActivity +1. TransparentDataEncryptionActivityListResult +1. TransparentDataEncryptionActivityProperties +1. UnlinkParameters + +#### Removed Struct Fields + +1. DatabaseUpdate.*DatabaseProperties +1. ManagedInstanceProperties.StorageAccountType +1. RestorableDroppedDatabaseProperties.ElasticPoolID +1. TransparentDataEncryptionProperties.Status + +### Signature Changes + +#### Funcs + +1. ElasticPoolsClient.ListByServer + - Params + - From: context.Context, string, string, *int32 + - To: context.Context, string, string, *int64 +1. ElasticPoolsClient.ListByServerComplete + - Params + - From: context.Context, string, string, *int32 + - To: context.Context, string, string, *int64 +1. ElasticPoolsClient.ListByServerPreparer + - Params + - From: context.Context, string, string, *int32 + - To: context.Context, string, string, *int64 +1. LedgerDigestUploadsClient.CreateOrUpdate + - Returns + - From: LedgerDigestUploads, error + - To: LedgerDigestUploadsCreateOrUpdateFuture, error +1. LedgerDigestUploadsClient.CreateOrUpdateSender + - Returns + - From: *http.Response, error + - To: LedgerDigestUploadsCreateOrUpdateFuture, error +1. LedgerDigestUploadsClient.Disable + - Returns + - From: LedgerDigestUploads, error + - To: LedgerDigestUploadsDisableFuture, error +1. LedgerDigestUploadsClient.DisableSender + - Returns + - From: *http.Response, error + - To: LedgerDigestUploadsDisableFuture, error +1. ReplicationLinksClient.FailoverAllowDataLossResponder + - Returns + - From: autorest.Response, error + - To: ReplicationLink, error +1. ReplicationLinksClient.FailoverResponder + - Returns + - From: autorest.Response, error + - To: ReplicationLink, error +1. ServerConnectionPoliciesClient.CreateOrUpdate + - Returns + - From: ServerConnectionPolicy, error + - To: ServerConnectionPoliciesCreateOrUpdateFuture, error +1. ServerConnectionPoliciesClient.CreateOrUpdateSender + - Returns + - From: *http.Response, error + - To: ServerConnectionPoliciesCreateOrUpdateFuture, error +1. SyncGroupsClient.ListLogs + - Params + - From: context.Context, string, string, string, string, string, string, string, string + - To: context.Context, string, string, string, string, string, string, SyncGroupsType, string +1. SyncGroupsClient.ListLogsComplete + - Params + - From: context.Context, string, string, string, string, string, string, string, string + - To: context.Context, string, string, string, string, string, string, SyncGroupsType, string +1. SyncGroupsClient.ListLogsPreparer + - Params + - From: context.Context, string, string, string, string, string, string, string, string + - To: context.Context, string, string, string, string, string, string, SyncGroupsType, string +1. TransparentDataEncryptionsClient.CreateOrUpdate + - Params + - From: context.Context, string, string, string, TransparentDataEncryption + - To: context.Context, string, string, string, LogicalDatabaseTransparentDataEncryption + - Returns + - From: TransparentDataEncryption, error + - To: LogicalDatabaseTransparentDataEncryption, error +1. TransparentDataEncryptionsClient.CreateOrUpdatePreparer + - Params + - From: context.Context, string, string, string, TransparentDataEncryption + - To: context.Context, string, string, string, LogicalDatabaseTransparentDataEncryption +1. TransparentDataEncryptionsClient.CreateOrUpdateResponder + - Returns + - From: TransparentDataEncryption, error + - To: LogicalDatabaseTransparentDataEncryption, error +1. TransparentDataEncryptionsClient.Get + - Returns + - From: TransparentDataEncryption, error + - To: LogicalDatabaseTransparentDataEncryption, error +1. TransparentDataEncryptionsClient.GetResponder + - Returns + - From: TransparentDataEncryption, error + - To: LogicalDatabaseTransparentDataEncryption, error + +#### Struct Fields + +1. CopyLongTermRetentionBackupParametersProperties.TargetBackupStorageRedundancy changed type from TargetBackupStorageRedundancy to BackupStorageRedundancy +1. DatabaseProperties.CurrentBackupStorageRedundancy changed type from CurrentBackupStorageRedundancy to BackupStorageRedundancy +1. DatabaseProperties.RequestedBackupStorageRedundancy changed type from RequestedBackupStorageRedundancy to BackupStorageRedundancy +1. ReplicationLinksFailoverAllowDataLossFuture.Result changed type from func(ReplicationLinksClient) (autorest.Response, error) to func(ReplicationLinksClient) (ReplicationLink, error) +1. ReplicationLinksFailoverFuture.Result changed type from func(ReplicationLinksClient) (autorest.Response, error) to func(ReplicationLinksClient) (ReplicationLink, error) +1. RestorableDroppedDatabaseProperties.BackupStorageRedundancy changed type from BackupStorageRedundancy1 to BackupStorageRedundancy +1. StorageCapability.StorageAccountType changed type from StorageAccountType1 to StorageAccountType +1. UpdateLongTermRetentionBackupParametersProperties.RequestedBackupStorageRedundancy changed type from RequestedBackupStorageRedundancy to BackupStorageRedundancy + +## Additive Changes + +### New Constants + +1. AdvancedThreatProtectionState.AdvancedThreatProtectionStateDisabled +1. AdvancedThreatProtectionState.AdvancedThreatProtectionStateEnabled +1. AdvancedThreatProtectionState.AdvancedThreatProtectionStateNew +1. BackupStorageRedundancy.BackupStorageRedundancyGeoZone +1. DatabaseIdentityType.DatabaseIdentityTypeNone +1. DatabaseIdentityType.DatabaseIdentityTypeUserAssigned +1. DatabaseStatus.DatabaseStatusStarting +1. DatabaseStatus.DatabaseStatusStopped +1. DatabaseStatus.DatabaseStatusStopping +1. IdentityType.IdentityTypeSystemAssignedUserAssigned +1. ProvisioningState1.ProvisioningState1Accepted +1. ProvisioningState1.ProvisioningState1Canceled +1. ProvisioningState1.ProvisioningState1Created +1. ProvisioningState1.ProvisioningState1Deleted +1. ProvisioningState1.ProvisioningState1NotSpecified +1. ProvisioningState1.ProvisioningState1Registering +1. ProvisioningState1.ProvisioningState1Running +1. ProvisioningState1.ProvisioningState1TimedOut +1. ProvisioningState1.ProvisioningState1Unrecognized +1. ReplicationMode.ReplicationModeAsync +1. ReplicationMode.ReplicationModeSync +1. ServicePrincipalType.ServicePrincipalTypeNone +1. ServicePrincipalType.ServicePrincipalTypeSystemAssigned +1. SyncGroupsType.SyncGroupsTypeAll +1. SyncGroupsType.SyncGroupsTypeError +1. SyncGroupsType.SyncGroupsTypeSuccess +1. SyncGroupsType.SyncGroupsTypeWarning + +### New Funcs + +1. *DatabaseAdvancedThreatProtection.UnmarshalJSON([]byte) error +1. *DatabaseAdvancedThreatProtectionListResultIterator.Next() error +1. *DatabaseAdvancedThreatProtectionListResultIterator.NextWithContext(context.Context) error +1. *DatabaseAdvancedThreatProtectionListResultPage.Next() error +1. *DatabaseAdvancedThreatProtectionListResultPage.NextWithContext(context.Context) error +1. *DistributedAvailabilityGroup.UnmarshalJSON([]byte) error +1. *DistributedAvailabilityGroupsCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *DistributedAvailabilityGroupsDeleteFuture.UnmarshalJSON([]byte) error +1. *DistributedAvailabilityGroupsListResultIterator.Next() error +1. *DistributedAvailabilityGroupsListResultIterator.NextWithContext(context.Context) error +1. *DistributedAvailabilityGroupsListResultPage.Next() error +1. *DistributedAvailabilityGroupsListResultPage.NextWithContext(context.Context) error +1. *DistributedAvailabilityGroupsUpdateFuture.UnmarshalJSON([]byte) error +1. *EndpointCertificate.UnmarshalJSON([]byte) error +1. *EndpointCertificateListResultIterator.Next() error +1. *EndpointCertificateListResultIterator.NextWithContext(context.Context) error +1. *EndpointCertificateListResultPage.Next() error +1. *EndpointCertificateListResultPage.NextWithContext(context.Context) error +1. *IPv6FirewallRule.UnmarshalJSON([]byte) error +1. *IPv6FirewallRuleListResultIterator.Next() error +1. *IPv6FirewallRuleListResultIterator.NextWithContext(context.Context) error +1. *IPv6FirewallRuleListResultPage.Next() error +1. *IPv6FirewallRuleListResultPage.NextWithContext(context.Context) error +1. *LedgerDigestUploadsCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *LedgerDigestUploadsDisableFuture.UnmarshalJSON([]byte) error +1. *LogicalDatabaseTransparentDataEncryption.UnmarshalJSON([]byte) error +1. *LogicalDatabaseTransparentDataEncryptionListResultIterator.Next() error +1. *LogicalDatabaseTransparentDataEncryptionListResultIterator.NextWithContext(context.Context) error +1. *LogicalDatabaseTransparentDataEncryptionListResultPage.Next() error +1. *LogicalDatabaseTransparentDataEncryptionListResultPage.NextWithContext(context.Context) error +1. *LogicalServerAdvancedThreatProtectionListResultIterator.Next() error +1. *LogicalServerAdvancedThreatProtectionListResultIterator.NextWithContext(context.Context) error +1. *LogicalServerAdvancedThreatProtectionListResultPage.Next() error +1. *LogicalServerAdvancedThreatProtectionListResultPage.NextWithContext(context.Context) error +1. *ManagedServerDNSAlias.UnmarshalJSON([]byte) error +1. *ManagedServerDNSAliasListResultIterator.Next() error +1. *ManagedServerDNSAliasListResultIterator.NextWithContext(context.Context) error +1. *ManagedServerDNSAliasListResultPage.Next() error +1. *ManagedServerDNSAliasListResultPage.NextWithContext(context.Context) error +1. *ManagedServerDNSAliasesAcquireFuture.UnmarshalJSON([]byte) error +1. *ManagedServerDNSAliasesCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *ManagedServerDNSAliasesDeleteFuture.UnmarshalJSON([]byte) error +1. *ServerAdvancedThreatProtection.UnmarshalJSON([]byte) error +1. *ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *ServerConnectionPoliciesCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *ServerConnectionPolicyListResultIterator.Next() error +1. *ServerConnectionPolicyListResultIterator.NextWithContext(context.Context) error +1. *ServerConnectionPolicyListResultPage.Next() error +1. *ServerConnectionPolicyListResultPage.NextWithContext(context.Context) error +1. *ServerTrustCertificate.UnmarshalJSON([]byte) error +1. *ServerTrustCertificatesCreateOrUpdateFuture.UnmarshalJSON([]byte) error +1. *ServerTrustCertificatesDeleteFuture.UnmarshalJSON([]byte) error +1. *ServerTrustCertificatesListResultIterator.Next() error +1. *ServerTrustCertificatesListResultIterator.NextWithContext(context.Context) error +1. *ServerTrustCertificatesListResultPage.Next() error +1. *ServerTrustCertificatesListResultPage.NextWithContext(context.Context) error +1. AdvancedThreatProtectionProperties.MarshalJSON() ([]byte, error) +1. DatabaseAdvancedThreatProtection.MarshalJSON() ([]byte, error) +1. DatabaseAdvancedThreatProtectionListResult.IsEmpty() bool +1. DatabaseAdvancedThreatProtectionListResult.MarshalJSON() ([]byte, error) +1. DatabaseAdvancedThreatProtectionListResultIterator.NotDone() bool +1. DatabaseAdvancedThreatProtectionListResultIterator.Response() DatabaseAdvancedThreatProtectionListResult +1. DatabaseAdvancedThreatProtectionListResultIterator.Value() DatabaseAdvancedThreatProtection +1. DatabaseAdvancedThreatProtectionListResultPage.NotDone() bool +1. DatabaseAdvancedThreatProtectionListResultPage.Response() DatabaseAdvancedThreatProtectionListResult +1. DatabaseAdvancedThreatProtectionListResultPage.Values() []DatabaseAdvancedThreatProtection +1. DatabaseAdvancedThreatProtectionSettingsClient.CreateOrUpdate(context.Context, string, string, string, DatabaseAdvancedThreatProtection) (DatabaseAdvancedThreatProtection, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.CreateOrUpdatePreparer(context.Context, string, string, string, DatabaseAdvancedThreatProtection) (*http.Request, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.CreateOrUpdateResponder(*http.Response) (DatabaseAdvancedThreatProtection, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.CreateOrUpdateSender(*http.Request) (*http.Response, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.Get(context.Context, string, string, string) (DatabaseAdvancedThreatProtection, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.GetResponder(*http.Response) (DatabaseAdvancedThreatProtection, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.GetSender(*http.Request) (*http.Response, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabase(context.Context, string, string, string) (DatabaseAdvancedThreatProtectionListResultPage, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabaseComplete(context.Context, string, string, string) (DatabaseAdvancedThreatProtectionListResultIterator, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabasePreparer(context.Context, string, string, string) (*http.Request, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabaseResponder(*http.Response) (DatabaseAdvancedThreatProtectionListResult, error) +1. DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabaseSender(*http.Request) (*http.Response, error) +1. DatabaseIdentity.MarshalJSON() ([]byte, error) +1. DatabaseUpdateProperties.MarshalJSON() ([]byte, error) +1. DatabaseUserIdentity.MarshalJSON() ([]byte, error) +1. DistributedAvailabilityGroup.MarshalJSON() ([]byte, error) +1. DistributedAvailabilityGroupProperties.MarshalJSON() ([]byte, error) +1. DistributedAvailabilityGroupsClient.CreateOrUpdate(context.Context, string, string, string, DistributedAvailabilityGroup) (DistributedAvailabilityGroupsCreateOrUpdateFuture, error) +1. DistributedAvailabilityGroupsClient.CreateOrUpdatePreparer(context.Context, string, string, string, DistributedAvailabilityGroup) (*http.Request, error) +1. DistributedAvailabilityGroupsClient.CreateOrUpdateResponder(*http.Response) (DistributedAvailabilityGroup, error) +1. DistributedAvailabilityGroupsClient.CreateOrUpdateSender(*http.Request) (DistributedAvailabilityGroupsCreateOrUpdateFuture, error) +1. DistributedAvailabilityGroupsClient.Delete(context.Context, string, string, string) (DistributedAvailabilityGroupsDeleteFuture, error) +1. DistributedAvailabilityGroupsClient.DeletePreparer(context.Context, string, string, string) (*http.Request, error) +1. DistributedAvailabilityGroupsClient.DeleteResponder(*http.Response) (autorest.Response, error) +1. DistributedAvailabilityGroupsClient.DeleteSender(*http.Request) (DistributedAvailabilityGroupsDeleteFuture, error) +1. DistributedAvailabilityGroupsClient.Get(context.Context, string, string, string) (DistributedAvailabilityGroup, error) +1. DistributedAvailabilityGroupsClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. DistributedAvailabilityGroupsClient.GetResponder(*http.Response) (DistributedAvailabilityGroup, error) +1. DistributedAvailabilityGroupsClient.GetSender(*http.Request) (*http.Response, error) +1. DistributedAvailabilityGroupsClient.ListByInstance(context.Context, string, string) (DistributedAvailabilityGroupsListResultPage, error) +1. DistributedAvailabilityGroupsClient.ListByInstanceComplete(context.Context, string, string) (DistributedAvailabilityGroupsListResultIterator, error) +1. DistributedAvailabilityGroupsClient.ListByInstancePreparer(context.Context, string, string) (*http.Request, error) +1. DistributedAvailabilityGroupsClient.ListByInstanceResponder(*http.Response) (DistributedAvailabilityGroupsListResult, error) +1. DistributedAvailabilityGroupsClient.ListByInstanceSender(*http.Request) (*http.Response, error) +1. DistributedAvailabilityGroupsClient.Update(context.Context, string, string, string, DistributedAvailabilityGroup) (DistributedAvailabilityGroupsUpdateFuture, error) +1. DistributedAvailabilityGroupsClient.UpdatePreparer(context.Context, string, string, string, DistributedAvailabilityGroup) (*http.Request, error) +1. DistributedAvailabilityGroupsClient.UpdateResponder(*http.Response) (DistributedAvailabilityGroup, error) +1. DistributedAvailabilityGroupsClient.UpdateSender(*http.Request) (DistributedAvailabilityGroupsUpdateFuture, error) +1. DistributedAvailabilityGroupsListResult.IsEmpty() bool +1. DistributedAvailabilityGroupsListResult.MarshalJSON() ([]byte, error) +1. DistributedAvailabilityGroupsListResultIterator.NotDone() bool +1. DistributedAvailabilityGroupsListResultIterator.Response() DistributedAvailabilityGroupsListResult +1. DistributedAvailabilityGroupsListResultIterator.Value() DistributedAvailabilityGroup +1. DistributedAvailabilityGroupsListResultPage.NotDone() bool +1. DistributedAvailabilityGroupsListResultPage.Response() DistributedAvailabilityGroupsListResult +1. DistributedAvailabilityGroupsListResultPage.Values() []DistributedAvailabilityGroup +1. EndpointCertificate.MarshalJSON() ([]byte, error) +1. EndpointCertificateListResult.IsEmpty() bool +1. EndpointCertificateListResult.MarshalJSON() ([]byte, error) +1. EndpointCertificateListResultIterator.NotDone() bool +1. EndpointCertificateListResultIterator.Response() EndpointCertificateListResult +1. EndpointCertificateListResultIterator.Value() EndpointCertificate +1. EndpointCertificateListResultPage.NotDone() bool +1. EndpointCertificateListResultPage.Response() EndpointCertificateListResult +1. EndpointCertificateListResultPage.Values() []EndpointCertificate +1. EndpointCertificatesClient.Get(context.Context, string, string, string) (EndpointCertificate, error) +1. EndpointCertificatesClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. EndpointCertificatesClient.GetResponder(*http.Response) (EndpointCertificate, error) +1. EndpointCertificatesClient.GetSender(*http.Request) (*http.Response, error) +1. EndpointCertificatesClient.ListByInstance(context.Context, string, string) (EndpointCertificateListResultPage, error) +1. EndpointCertificatesClient.ListByInstanceComplete(context.Context, string, string) (EndpointCertificateListResultIterator, error) +1. EndpointCertificatesClient.ListByInstancePreparer(context.Context, string, string) (*http.Request, error) +1. EndpointCertificatesClient.ListByInstanceResponder(*http.Response) (EndpointCertificateListResult, error) +1. EndpointCertificatesClient.ListByInstanceSender(*http.Request) (*http.Response, error) +1. IPv6FirewallRule.MarshalJSON() ([]byte, error) +1. IPv6FirewallRuleListResult.IsEmpty() bool +1. IPv6FirewallRuleListResult.MarshalJSON() ([]byte, error) +1. IPv6FirewallRuleListResultIterator.NotDone() bool +1. IPv6FirewallRuleListResultIterator.Response() IPv6FirewallRuleListResult +1. IPv6FirewallRuleListResultIterator.Value() IPv6FirewallRule +1. IPv6FirewallRuleListResultPage.NotDone() bool +1. IPv6FirewallRuleListResultPage.Response() IPv6FirewallRuleListResult +1. IPv6FirewallRuleListResultPage.Values() []IPv6FirewallRule +1. IPv6FirewallRulesClient.CreateOrUpdate(context.Context, string, string, string, IPv6FirewallRule) (IPv6FirewallRule, error) +1. IPv6FirewallRulesClient.CreateOrUpdatePreparer(context.Context, string, string, string, IPv6FirewallRule) (*http.Request, error) +1. IPv6FirewallRulesClient.CreateOrUpdateResponder(*http.Response) (IPv6FirewallRule, error) +1. IPv6FirewallRulesClient.CreateOrUpdateSender(*http.Request) (*http.Response, error) +1. IPv6FirewallRulesClient.Delete(context.Context, string, string, string) (autorest.Response, error) +1. IPv6FirewallRulesClient.DeletePreparer(context.Context, string, string, string) (*http.Request, error) +1. IPv6FirewallRulesClient.DeleteResponder(*http.Response) (autorest.Response, error) +1. IPv6FirewallRulesClient.DeleteSender(*http.Request) (*http.Response, error) +1. IPv6FirewallRulesClient.Get(context.Context, string, string, string) (IPv6FirewallRule, error) +1. IPv6FirewallRulesClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. IPv6FirewallRulesClient.GetResponder(*http.Response) (IPv6FirewallRule, error) +1. IPv6FirewallRulesClient.GetSender(*http.Request) (*http.Response, error) +1. IPv6FirewallRulesClient.ListByServer(context.Context, string, string) (IPv6FirewallRuleListResultPage, error) +1. IPv6FirewallRulesClient.ListByServerComplete(context.Context, string, string) (IPv6FirewallRuleListResultIterator, error) +1. IPv6FirewallRulesClient.ListByServerPreparer(context.Context, string, string) (*http.Request, error) +1. IPv6FirewallRulesClient.ListByServerResponder(*http.Response) (IPv6FirewallRuleListResult, error) +1. IPv6FirewallRulesClient.ListByServerSender(*http.Request) (*http.Response, error) +1. LogicalDatabaseTransparentDataEncryption.MarshalJSON() ([]byte, error) +1. LogicalDatabaseTransparentDataEncryptionListResult.IsEmpty() bool +1. LogicalDatabaseTransparentDataEncryptionListResult.MarshalJSON() ([]byte, error) +1. LogicalDatabaseTransparentDataEncryptionListResultIterator.NotDone() bool +1. LogicalDatabaseTransparentDataEncryptionListResultIterator.Response() LogicalDatabaseTransparentDataEncryptionListResult +1. LogicalDatabaseTransparentDataEncryptionListResultIterator.Value() LogicalDatabaseTransparentDataEncryption +1. LogicalDatabaseTransparentDataEncryptionListResultPage.NotDone() bool +1. LogicalDatabaseTransparentDataEncryptionListResultPage.Response() LogicalDatabaseTransparentDataEncryptionListResult +1. LogicalDatabaseTransparentDataEncryptionListResultPage.Values() []LogicalDatabaseTransparentDataEncryption +1. LogicalServerAdvancedThreatProtectionListResult.IsEmpty() bool +1. LogicalServerAdvancedThreatProtectionListResult.MarshalJSON() ([]byte, error) +1. LogicalServerAdvancedThreatProtectionListResultIterator.NotDone() bool +1. LogicalServerAdvancedThreatProtectionListResultIterator.Response() LogicalServerAdvancedThreatProtectionListResult +1. LogicalServerAdvancedThreatProtectionListResultIterator.Value() ServerAdvancedThreatProtection +1. LogicalServerAdvancedThreatProtectionListResultPage.NotDone() bool +1. LogicalServerAdvancedThreatProtectionListResultPage.Response() LogicalServerAdvancedThreatProtectionListResult +1. LogicalServerAdvancedThreatProtectionListResultPage.Values() []ServerAdvancedThreatProtection +1. ManagedServerDNSAlias.MarshalJSON() ([]byte, error) +1. ManagedServerDNSAliasListResult.IsEmpty() bool +1. ManagedServerDNSAliasListResult.MarshalJSON() ([]byte, error) +1. ManagedServerDNSAliasListResultIterator.NotDone() bool +1. ManagedServerDNSAliasListResultIterator.Response() ManagedServerDNSAliasListResult +1. ManagedServerDNSAliasListResultIterator.Value() ManagedServerDNSAlias +1. ManagedServerDNSAliasListResultPage.NotDone() bool +1. ManagedServerDNSAliasListResultPage.Response() ManagedServerDNSAliasListResult +1. ManagedServerDNSAliasListResultPage.Values() []ManagedServerDNSAlias +1. ManagedServerDNSAliasProperties.MarshalJSON() ([]byte, error) +1. ManagedServerDNSAliasesClient.Acquire(context.Context, string, string, string, ManagedServerDNSAliasAcquisition) (ManagedServerDNSAliasesAcquireFuture, error) +1. ManagedServerDNSAliasesClient.AcquirePreparer(context.Context, string, string, string, ManagedServerDNSAliasAcquisition) (*http.Request, error) +1. ManagedServerDNSAliasesClient.AcquireResponder(*http.Response) (ManagedServerDNSAlias, error) +1. ManagedServerDNSAliasesClient.AcquireSender(*http.Request) (ManagedServerDNSAliasesAcquireFuture, error) +1. ManagedServerDNSAliasesClient.CreateOrUpdate(context.Context, string, string, string, ManagedServerDNSAliasCreation) (ManagedServerDNSAliasesCreateOrUpdateFuture, error) +1. ManagedServerDNSAliasesClient.CreateOrUpdatePreparer(context.Context, string, string, string, ManagedServerDNSAliasCreation) (*http.Request, error) +1. ManagedServerDNSAliasesClient.CreateOrUpdateResponder(*http.Response) (ManagedServerDNSAlias, error) +1. ManagedServerDNSAliasesClient.CreateOrUpdateSender(*http.Request) (ManagedServerDNSAliasesCreateOrUpdateFuture, error) +1. ManagedServerDNSAliasesClient.Delete(context.Context, string, string, string) (ManagedServerDNSAliasesDeleteFuture, error) +1. ManagedServerDNSAliasesClient.DeletePreparer(context.Context, string, string, string) (*http.Request, error) +1. ManagedServerDNSAliasesClient.DeleteResponder(*http.Response) (autorest.Response, error) +1. ManagedServerDNSAliasesClient.DeleteSender(*http.Request) (ManagedServerDNSAliasesDeleteFuture, error) +1. ManagedServerDNSAliasesClient.Get(context.Context, string, string, string) (ManagedServerDNSAlias, error) +1. ManagedServerDNSAliasesClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. ManagedServerDNSAliasesClient.GetResponder(*http.Response) (ManagedServerDNSAlias, error) +1. ManagedServerDNSAliasesClient.GetSender(*http.Request) (*http.Response, error) +1. ManagedServerDNSAliasesClient.ListByManagedInstance(context.Context, string, string) (ManagedServerDNSAliasListResultPage, error) +1. ManagedServerDNSAliasesClient.ListByManagedInstanceComplete(context.Context, string, string) (ManagedServerDNSAliasListResultIterator, error) +1. ManagedServerDNSAliasesClient.ListByManagedInstancePreparer(context.Context, string, string) (*http.Request, error) +1. ManagedServerDNSAliasesClient.ListByManagedInstanceResponder(*http.Response) (ManagedServerDNSAliasListResult, error) +1. ManagedServerDNSAliasesClient.ListByManagedInstanceSender(*http.Request) (*http.Response, error) +1. NewDatabaseAdvancedThreatProtectionListResultIterator(DatabaseAdvancedThreatProtectionListResultPage) DatabaseAdvancedThreatProtectionListResultIterator +1. NewDatabaseAdvancedThreatProtectionListResultPage(DatabaseAdvancedThreatProtectionListResult, func(context.Context, DatabaseAdvancedThreatProtectionListResult) (DatabaseAdvancedThreatProtectionListResult, error)) DatabaseAdvancedThreatProtectionListResultPage +1. NewDatabaseAdvancedThreatProtectionSettingsClient(string) DatabaseAdvancedThreatProtectionSettingsClient +1. NewDatabaseAdvancedThreatProtectionSettingsClientWithBaseURI(string, string) DatabaseAdvancedThreatProtectionSettingsClient +1. NewDistributedAvailabilityGroupsClient(string) DistributedAvailabilityGroupsClient +1. NewDistributedAvailabilityGroupsClientWithBaseURI(string, string) DistributedAvailabilityGroupsClient +1. NewDistributedAvailabilityGroupsListResultIterator(DistributedAvailabilityGroupsListResultPage) DistributedAvailabilityGroupsListResultIterator +1. NewDistributedAvailabilityGroupsListResultPage(DistributedAvailabilityGroupsListResult, func(context.Context, DistributedAvailabilityGroupsListResult) (DistributedAvailabilityGroupsListResult, error)) DistributedAvailabilityGroupsListResultPage +1. NewEndpointCertificateListResultIterator(EndpointCertificateListResultPage) EndpointCertificateListResultIterator +1. NewEndpointCertificateListResultPage(EndpointCertificateListResult, func(context.Context, EndpointCertificateListResult) (EndpointCertificateListResult, error)) EndpointCertificateListResultPage +1. NewEndpointCertificatesClient(string) EndpointCertificatesClient +1. NewEndpointCertificatesClientWithBaseURI(string, string) EndpointCertificatesClient +1. NewIPv6FirewallRuleListResultIterator(IPv6FirewallRuleListResultPage) IPv6FirewallRuleListResultIterator +1. NewIPv6FirewallRuleListResultPage(IPv6FirewallRuleListResult, func(context.Context, IPv6FirewallRuleListResult) (IPv6FirewallRuleListResult, error)) IPv6FirewallRuleListResultPage +1. NewIPv6FirewallRulesClient(string) IPv6FirewallRulesClient +1. NewIPv6FirewallRulesClientWithBaseURI(string, string) IPv6FirewallRulesClient +1. NewLogicalDatabaseTransparentDataEncryptionListResultIterator(LogicalDatabaseTransparentDataEncryptionListResultPage) LogicalDatabaseTransparentDataEncryptionListResultIterator +1. NewLogicalDatabaseTransparentDataEncryptionListResultPage(LogicalDatabaseTransparentDataEncryptionListResult, func(context.Context, LogicalDatabaseTransparentDataEncryptionListResult) (LogicalDatabaseTransparentDataEncryptionListResult, error)) LogicalDatabaseTransparentDataEncryptionListResultPage +1. NewLogicalServerAdvancedThreatProtectionListResultIterator(LogicalServerAdvancedThreatProtectionListResultPage) LogicalServerAdvancedThreatProtectionListResultIterator +1. NewLogicalServerAdvancedThreatProtectionListResultPage(LogicalServerAdvancedThreatProtectionListResult, func(context.Context, LogicalServerAdvancedThreatProtectionListResult) (LogicalServerAdvancedThreatProtectionListResult, error)) LogicalServerAdvancedThreatProtectionListResultPage +1. NewManagedServerDNSAliasListResultIterator(ManagedServerDNSAliasListResultPage) ManagedServerDNSAliasListResultIterator +1. NewManagedServerDNSAliasListResultPage(ManagedServerDNSAliasListResult, func(context.Context, ManagedServerDNSAliasListResult) (ManagedServerDNSAliasListResult, error)) ManagedServerDNSAliasListResultPage +1. NewManagedServerDNSAliasesClient(string) ManagedServerDNSAliasesClient +1. NewManagedServerDNSAliasesClientWithBaseURI(string, string) ManagedServerDNSAliasesClient +1. NewServerAdvancedThreatProtectionSettingsClient(string) ServerAdvancedThreatProtectionSettingsClient +1. NewServerAdvancedThreatProtectionSettingsClientWithBaseURI(string, string) ServerAdvancedThreatProtectionSettingsClient +1. NewServerConnectionPolicyListResultIterator(ServerConnectionPolicyListResultPage) ServerConnectionPolicyListResultIterator +1. NewServerConnectionPolicyListResultPage(ServerConnectionPolicyListResult, func(context.Context, ServerConnectionPolicyListResult) (ServerConnectionPolicyListResult, error)) ServerConnectionPolicyListResultPage +1. NewServerTrustCertificatesClient(string) ServerTrustCertificatesClient +1. NewServerTrustCertificatesClientWithBaseURI(string, string) ServerTrustCertificatesClient +1. NewServerTrustCertificatesListResultIterator(ServerTrustCertificatesListResultPage) ServerTrustCertificatesListResultIterator +1. NewServerTrustCertificatesListResultPage(ServerTrustCertificatesListResult, func(context.Context, ServerTrustCertificatesListResult) (ServerTrustCertificatesListResult, error)) ServerTrustCertificatesListResultPage +1. PossibleAdvancedThreatProtectionStateValues() []AdvancedThreatProtectionState +1. PossibleDatabaseIdentityTypeValues() []DatabaseIdentityType +1. PossibleReplicationModeValues() []ReplicationMode +1. PossibleServicePrincipalTypeValues() []ServicePrincipalType +1. PossibleSyncGroupsTypeValues() []SyncGroupsType +1. ServerAdvancedThreatProtection.MarshalJSON() ([]byte, error) +1. ServerAdvancedThreatProtectionSettingsClient.CreateOrUpdate(context.Context, string, string, ServerAdvancedThreatProtection) (ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture, error) +1. ServerAdvancedThreatProtectionSettingsClient.CreateOrUpdatePreparer(context.Context, string, string, ServerAdvancedThreatProtection) (*http.Request, error) +1. ServerAdvancedThreatProtectionSettingsClient.CreateOrUpdateResponder(*http.Response) (ServerAdvancedThreatProtection, error) +1. ServerAdvancedThreatProtectionSettingsClient.CreateOrUpdateSender(*http.Request) (ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture, error) +1. ServerAdvancedThreatProtectionSettingsClient.Get(context.Context, string, string) (ServerAdvancedThreatProtection, error) +1. ServerAdvancedThreatProtectionSettingsClient.GetPreparer(context.Context, string, string) (*http.Request, error) +1. ServerAdvancedThreatProtectionSettingsClient.GetResponder(*http.Response) (ServerAdvancedThreatProtection, error) +1. ServerAdvancedThreatProtectionSettingsClient.GetSender(*http.Request) (*http.Response, error) +1. ServerAdvancedThreatProtectionSettingsClient.ListByServer(context.Context, string, string) (LogicalServerAdvancedThreatProtectionListResultPage, error) +1. ServerAdvancedThreatProtectionSettingsClient.ListByServerComplete(context.Context, string, string) (LogicalServerAdvancedThreatProtectionListResultIterator, error) +1. ServerAdvancedThreatProtectionSettingsClient.ListByServerPreparer(context.Context, string, string) (*http.Request, error) +1. ServerAdvancedThreatProtectionSettingsClient.ListByServerResponder(*http.Response) (LogicalServerAdvancedThreatProtectionListResult, error) +1. ServerAdvancedThreatProtectionSettingsClient.ListByServerSender(*http.Request) (*http.Response, error) +1. ServerConnectionPoliciesClient.ListByServer(context.Context, string, string) (ServerConnectionPolicyListResultPage, error) +1. ServerConnectionPoliciesClient.ListByServerComplete(context.Context, string, string) (ServerConnectionPolicyListResultIterator, error) +1. ServerConnectionPoliciesClient.ListByServerPreparer(context.Context, string, string) (*http.Request, error) +1. ServerConnectionPoliciesClient.ListByServerResponder(*http.Response) (ServerConnectionPolicyListResult, error) +1. ServerConnectionPoliciesClient.ListByServerSender(*http.Request) (*http.Response, error) +1. ServerConnectionPolicyListResult.IsEmpty() bool +1. ServerConnectionPolicyListResult.MarshalJSON() ([]byte, error) +1. ServerConnectionPolicyListResultIterator.NotDone() bool +1. ServerConnectionPolicyListResultIterator.Response() ServerConnectionPolicyListResult +1. ServerConnectionPolicyListResultIterator.Value() ServerConnectionPolicy +1. ServerConnectionPolicyListResultPage.NotDone() bool +1. ServerConnectionPolicyListResultPage.Response() ServerConnectionPolicyListResult +1. ServerConnectionPolicyListResultPage.Values() []ServerConnectionPolicy +1. ServerTrustCertificate.MarshalJSON() ([]byte, error) +1. ServerTrustCertificateProperties.MarshalJSON() ([]byte, error) +1. ServerTrustCertificatesClient.CreateOrUpdate(context.Context, string, string, string, ServerTrustCertificate) (ServerTrustCertificatesCreateOrUpdateFuture, error) +1. ServerTrustCertificatesClient.CreateOrUpdatePreparer(context.Context, string, string, string, ServerTrustCertificate) (*http.Request, error) +1. ServerTrustCertificatesClient.CreateOrUpdateResponder(*http.Response) (ServerTrustCertificate, error) +1. ServerTrustCertificatesClient.CreateOrUpdateSender(*http.Request) (ServerTrustCertificatesCreateOrUpdateFuture, error) +1. ServerTrustCertificatesClient.Delete(context.Context, string, string, string) (ServerTrustCertificatesDeleteFuture, error) +1. ServerTrustCertificatesClient.DeletePreparer(context.Context, string, string, string) (*http.Request, error) +1. ServerTrustCertificatesClient.DeleteResponder(*http.Response) (autorest.Response, error) +1. ServerTrustCertificatesClient.DeleteSender(*http.Request) (ServerTrustCertificatesDeleteFuture, error) +1. ServerTrustCertificatesClient.Get(context.Context, string, string, string) (ServerTrustCertificate, error) +1. ServerTrustCertificatesClient.GetPreparer(context.Context, string, string, string) (*http.Request, error) +1. ServerTrustCertificatesClient.GetResponder(*http.Response) (ServerTrustCertificate, error) +1. ServerTrustCertificatesClient.GetSender(*http.Request) (*http.Response, error) +1. ServerTrustCertificatesClient.ListByInstance(context.Context, string, string) (ServerTrustCertificatesListResultPage, error) +1. ServerTrustCertificatesClient.ListByInstanceComplete(context.Context, string, string) (ServerTrustCertificatesListResultIterator, error) +1. ServerTrustCertificatesClient.ListByInstancePreparer(context.Context, string, string) (*http.Request, error) +1. ServerTrustCertificatesClient.ListByInstanceResponder(*http.Response) (ServerTrustCertificatesListResult, error) +1. ServerTrustCertificatesClient.ListByInstanceSender(*http.Request) (*http.Response, error) +1. ServerTrustCertificatesListResult.IsEmpty() bool +1. ServerTrustCertificatesListResult.MarshalJSON() ([]byte, error) +1. ServerTrustCertificatesListResultIterator.NotDone() bool +1. ServerTrustCertificatesListResultIterator.Response() ServerTrustCertificatesListResult +1. ServerTrustCertificatesListResultIterator.Value() ServerTrustCertificate +1. ServerTrustCertificatesListResultPage.NotDone() bool +1. ServerTrustCertificatesListResultPage.Response() ServerTrustCertificatesListResult +1. ServerTrustCertificatesListResultPage.Values() []ServerTrustCertificate +1. ServicePrincipal.MarshalJSON() ([]byte, error) +1. TransparentDataEncryptionsClient.ListByDatabase(context.Context, string, string, string) (LogicalDatabaseTransparentDataEncryptionListResultPage, error) +1. TransparentDataEncryptionsClient.ListByDatabaseComplete(context.Context, string, string, string) (LogicalDatabaseTransparentDataEncryptionListResultIterator, error) +1. TransparentDataEncryptionsClient.ListByDatabasePreparer(context.Context, string, string, string) (*http.Request, error) +1. TransparentDataEncryptionsClient.ListByDatabaseResponder(*http.Response) (LogicalDatabaseTransparentDataEncryptionListResult, error) +1. TransparentDataEncryptionsClient.ListByDatabaseSender(*http.Request) (*http.Response, error) + +### Struct Changes + +#### New Structs + +1. AdvancedThreatProtectionProperties +1. DatabaseAdvancedThreatProtection +1. DatabaseAdvancedThreatProtectionListResult +1. DatabaseAdvancedThreatProtectionListResultIterator +1. DatabaseAdvancedThreatProtectionListResultPage +1. DatabaseAdvancedThreatProtectionSettingsClient +1. DatabaseIdentity +1. DatabaseUpdateProperties +1. DatabaseUserIdentity +1. DistributedAvailabilityGroup +1. DistributedAvailabilityGroupProperties +1. DistributedAvailabilityGroupsClient +1. DistributedAvailabilityGroupsCreateOrUpdateFuture +1. DistributedAvailabilityGroupsDeleteFuture +1. DistributedAvailabilityGroupsListResult +1. DistributedAvailabilityGroupsListResultIterator +1. DistributedAvailabilityGroupsListResultPage +1. DistributedAvailabilityGroupsUpdateFuture +1. EndpointCertificate +1. EndpointCertificateListResult +1. EndpointCertificateListResultIterator +1. EndpointCertificateListResultPage +1. EndpointCertificateProperties +1. EndpointCertificatesClient +1. IPv6FirewallRule +1. IPv6FirewallRuleListResult +1. IPv6FirewallRuleListResultIterator +1. IPv6FirewallRuleListResultPage +1. IPv6FirewallRulesClient +1. IPv6ServerFirewallRuleProperties +1. LedgerDigestUploadsCreateOrUpdateFuture +1. LedgerDigestUploadsDisableFuture +1. LogicalDatabaseTransparentDataEncryption +1. LogicalDatabaseTransparentDataEncryptionListResult +1. LogicalDatabaseTransparentDataEncryptionListResultIterator +1. LogicalDatabaseTransparentDataEncryptionListResultPage +1. LogicalServerAdvancedThreatProtectionListResult +1. LogicalServerAdvancedThreatProtectionListResultIterator +1. LogicalServerAdvancedThreatProtectionListResultPage +1. ManagedServerDNSAlias +1. ManagedServerDNSAliasAcquisition +1. ManagedServerDNSAliasCreation +1. ManagedServerDNSAliasListResult +1. ManagedServerDNSAliasListResultIterator +1. ManagedServerDNSAliasListResultPage +1. ManagedServerDNSAliasProperties +1. ManagedServerDNSAliasesAcquireFuture +1. ManagedServerDNSAliasesClient +1. ManagedServerDNSAliasesCreateOrUpdateFuture +1. ManagedServerDNSAliasesDeleteFuture +1. ServerAdvancedThreatProtection +1. ServerAdvancedThreatProtectionSettingsClient +1. ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture +1. ServerConnectionPoliciesCreateOrUpdateFuture +1. ServerConnectionPolicyListResult +1. ServerConnectionPolicyListResultIterator +1. ServerConnectionPolicyListResultPage +1. ServerTrustCertificate +1. ServerTrustCertificateProperties +1. ServerTrustCertificatesClient +1. ServerTrustCertificatesCreateOrUpdateFuture +1. ServerTrustCertificatesDeleteFuture +1. ServerTrustCertificatesListResult +1. ServerTrustCertificatesListResultIterator +1. ServerTrustCertificatesListResultPage +1. ServicePrincipal + +#### New Struct Fields + +1. Database.Identity +1. DatabaseBlobAuditingPolicyProperties.IsManagedIdentityInUse +1. DatabaseProperties.FederatedClientID +1. DatabaseProperties.SourceResourceID +1. DatabaseUpdate.*DatabaseUpdateProperties +1. DatabaseUpdate.Identity +1. ElasticPoolProperties.HighAvailabilityReplicaCount +1. ElasticPoolUpdateProperties.HighAvailabilityReplicaCount +1. ExtendedDatabaseBlobAuditingPolicyProperties.IsManagedIdentityInUse +1. ExtendedServerBlobAuditingPolicyProperties.IsManagedIdentityInUse +1. ManagedInstanceProperties.CurrentBackupStorageRedundancy +1. ManagedInstanceProperties.RequestedBackupStorageRedundancy +1. ManagedInstanceProperties.ServicePrincipal +1. ServerBlobAuditingPolicyProperties.IsManagedIdentityInUse +1. TransparentDataEncryptionProperties.State diff --git a/services/preview/sql/mgmt/v5.0/sql/_meta.json b/services/preview/sql/mgmt/v5.0/sql/_meta.json index fe8ee2dae0a5..7d597e01399e 100644 --- a/services/preview/sql/mgmt/v5.0/sql/_meta.json +++ b/services/preview/sql/mgmt/v5.0/sql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", "tag": "package-composite-v5", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseadvancedthreatprotectionsettings.go b/services/preview/sql/mgmt/v5.0/sql/databaseadvancedthreatprotectionsettings.go new file mode 100644 index 000000000000..144e6e776b16 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseadvancedthreatprotectionsettings.go @@ -0,0 +1,320 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DatabaseAdvancedThreatProtectionSettingsClient 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 DatabaseAdvancedThreatProtectionSettingsClient struct { + BaseClient +} + +// NewDatabaseAdvancedThreatProtectionSettingsClient creates an instance of the +// DatabaseAdvancedThreatProtectionSettingsClient client. +func NewDatabaseAdvancedThreatProtectionSettingsClient(subscriptionID string) DatabaseAdvancedThreatProtectionSettingsClient { + return NewDatabaseAdvancedThreatProtectionSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAdvancedThreatProtectionSettingsClientWithBaseURI creates an instance of the +// DatabaseAdvancedThreatProtectionSettingsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseAdvancedThreatProtectionSettingsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAdvancedThreatProtectionSettingsClient { + return DatabaseAdvancedThreatProtectionSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's Advanced Threat Protection state. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +// parameters - the database Advanced Threat Protection state. +func (client DatabaseAdvancedThreatProtectionSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAdvancedThreatProtection) (result DatabaseAdvancedThreatProtection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvancedThreatProtectionSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "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.DatabaseAdvancedThreatProtectionSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseAdvancedThreatProtectionSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAdvancedThreatProtection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advancedThreatProtectionName": autorest.Encode("path", "Default"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", 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 DatabaseAdvancedThreatProtectionSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseAdvancedThreatProtectionSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseAdvancedThreatProtection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's Advanced Threat Protection state. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseAdvancedThreatProtectionSettingsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAdvancedThreatProtection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvancedThreatProtectionSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "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.DatabaseAdvancedThreatProtectionSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAdvancedThreatProtectionSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advancedThreatProtectionName": autorest.Encode("path", "Default"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", 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 DatabaseAdvancedThreatProtectionSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAdvancedThreatProtectionSettingsClient) GetResponder(resp *http.Response) (result DatabaseAdvancedThreatProtection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database's Advanced Threat Protection states. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the database. +func (client DatabaseAdvancedThreatProtectionSettingsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAdvancedThreatProtectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabase") + defer func() { + sc := -1 + if result.datplr.Response.Response != nil { + sc = result.datplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.datplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.datplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.datplr.hasNextLink() && result.datplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseAdvancedThreatProtectionSettingsClient) ListByDatabasePreparer(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 = "2021-11-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}/advancedThreatProtectionSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAdvancedThreatProtectionSettingsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseAdvancedThreatProtectionSettingsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseAdvancedThreatProtectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseAdvancedThreatProtectionSettingsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseAdvancedThreatProtectionListResult) (result DatabaseAdvancedThreatProtectionListResult, err error) { + req, err := lastResults.databaseAdvancedThreatProtectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvancedThreatProtectionSettingsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseAdvancedThreatProtectionSettingsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAdvancedThreatProtectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvancedThreatProtectionSettingsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go index 466576ad5f57..9b77bfd9a55c 100644 --- a/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go @@ -83,7 +83,7 @@ func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -166,7 +166,7 @@ func (client DatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context.Context "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -250,7 +250,7 @@ func (client DatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer(ctx cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/databases.go b/services/preview/sql/mgmt/v5.0/sql/databases.go index 148a7b9a3c1f..3393ead14dcb 100644 --- a/services/preview/sql/mgmt/v5.0/sql/databases.go +++ b/services/preview/sql/mgmt/v5.0/sql/databases.go @@ -86,7 +86,7 @@ func (client DatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resour "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -172,7 +172,7 @@ func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -263,7 +263,7 @@ func (client DatabasesClient) ExportPreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -348,7 +348,7 @@ func (client DatabasesClient) FailoverPreparer(ctx context.Context, resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -439,7 +439,7 @@ func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -521,7 +521,7 @@ func (client DatabasesClient) ImportPreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -617,7 +617,7 @@ func (client DatabasesClient) ListByElasticPoolPreparer(ctx context.Context, res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -736,7 +736,7 @@ func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -858,7 +858,7 @@ func (client DatabasesClient) ListInaccessibleByServerPreparer(ctx context.Conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1127,7 +1127,7 @@ func (client DatabasesClient) PausePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1223,7 +1223,7 @@ func (client DatabasesClient) RenamePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1296,7 +1296,7 @@ func (client DatabasesClient) ResumePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1379,7 +1379,7 @@ func (client DatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1463,7 +1463,7 @@ func (client DatabasesClient) UpgradeDataWarehousePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go b/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go index deace584057c..7637a7d50a2c 100644 --- a/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go @@ -78,7 +78,7 @@ func (client DatabaseSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx con pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "resourceGroupName": autorest.Encode("path", resourceGroupName), - "securityAlertPolicyName": autorest.Encode("path", "default"), + "securityAlertPolicyName": autorest.Encode("path", "Default"), "serverName": autorest.Encode("path", serverName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -161,7 +161,7 @@ func (client DatabaseSecurityAlertPoliciesClient) GetPreparer(ctx context.Contex pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "resourceGroupName": autorest.Encode("path", resourceGroupName), - "securityAlertPolicyName": autorest.Encode("path", "default"), + "securityAlertPolicyName": autorest.Encode("path", "Default"), "serverName": autorest.Encode("path", serverName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } diff --git a/services/preview/sql/mgmt/v5.0/sql/distributedavailabilitygroups.go b/services/preview/sql/mgmt/v5.0/sql/distributedavailabilitygroups.go new file mode 100644 index 000000000000..78c05140f4e4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/distributedavailabilitygroups.go @@ -0,0 +1,483 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// DistributedAvailabilityGroupsClient 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 DistributedAvailabilityGroupsClient struct { + BaseClient +} + +// NewDistributedAvailabilityGroupsClient creates an instance of the DistributedAvailabilityGroupsClient client. +func NewDistributedAvailabilityGroupsClient(subscriptionID string) DistributedAvailabilityGroupsClient { + return NewDistributedAvailabilityGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDistributedAvailabilityGroupsClientWithBaseURI creates an instance of the DistributedAvailabilityGroupsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDistributedAvailabilityGroupsClientWithBaseURI(baseURI string, subscriptionID string) DistributedAvailabilityGroupsClient { + return DistributedAvailabilityGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a distributed availability group between Sql On-Prem and Sql Managed Instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// distributedAvailabilityGroupName - the distributed availability group name. +// parameters - the distributed availability group info. +func (client DistributedAvailabilityGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string, parameters DistributedAvailabilityGroup) (result DistributedAvailabilityGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DistributedAvailabilityGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string, parameters DistributedAvailabilityGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "distributedAvailabilityGroupName": autorest.Encode("path", distributedAvailabilityGroupName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}", 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 DistributedAvailabilityGroupsClient) CreateOrUpdateSender(req *http.Request) (future DistributedAvailabilityGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DistributedAvailabilityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result DistributedAvailabilityGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete drops a distributed availability group between Sql On-Prem and Sql Managed Instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// distributedAvailabilityGroupName - the distributed availability group name. +func (client DistributedAvailabilityGroupsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string) (result DistributedAvailabilityGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DistributedAvailabilityGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "distributedAvailabilityGroupName": autorest.Encode("path", distributedAvailabilityGroupName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}", 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 DistributedAvailabilityGroupsClient) DeleteSender(req *http.Request) (future DistributedAvailabilityGroupsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DistributedAvailabilityGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a distributed availability group info. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// distributedAvailabilityGroupName - the distributed availability group name. +func (client DistributedAvailabilityGroupsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string) (result DistributedAvailabilityGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "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.DistributedAvailabilityGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DistributedAvailabilityGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "distributedAvailabilityGroupName": autorest.Encode("path", distributedAvailabilityGroupName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}", 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 DistributedAvailabilityGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DistributedAvailabilityGroupsClient) GetResponder(resp *http.Response) (result DistributedAvailabilityGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of a distributed availability groups in instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client DistributedAvailabilityGroupsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result DistributedAvailabilityGroupsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsClient.ListByInstance") + defer func() { + sc := -1 + if result.daglr.Response.Response != nil { + sc = result.daglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.daglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.daglr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.daglr.hasNextLink() && result.daglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client DistributedAvailabilityGroupsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/distributedAvailabilityGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client DistributedAvailabilityGroupsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client DistributedAvailabilityGroupsClient) ListByInstanceResponder(resp *http.Response) (result DistributedAvailabilityGroupsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client DistributedAvailabilityGroupsClient) listByInstanceNextResults(ctx context.Context, lastResults DistributedAvailabilityGroupsListResult) (result DistributedAvailabilityGroupsListResult, err error) { + req, err := lastResults.distributedAvailabilityGroupsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client DistributedAvailabilityGroupsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result DistributedAvailabilityGroupsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Update updates a distributed availability group replication mode. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// distributedAvailabilityGroupName - the distributed availability group name. +// parameters - the distributed availability group info. +func (client DistributedAvailabilityGroupsClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string, parameters DistributedAvailabilityGroup) (result DistributedAvailabilityGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DistributedAvailabilityGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string, parameters DistributedAvailabilityGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "distributedAvailabilityGroupName": autorest.Encode("path", distributedAvailabilityGroupName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}", 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 DistributedAvailabilityGroupsClient) UpdateSender(req *http.Request) (future DistributedAvailabilityGroupsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DistributedAvailabilityGroupsClient) UpdateResponder(resp *http.Response) (result DistributedAvailabilityGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/elasticpools.go b/services/preview/sql/mgmt/v5.0/sql/elasticpools.go index f69d6d42e21f..7ca8f52c2bb9 100644 --- a/services/preview/sql/mgmt/v5.0/sql/elasticpools.go +++ b/services/preview/sql/mgmt/v5.0/sql/elasticpools.go @@ -82,7 +82,7 @@ func (client ElasticPoolsClient) CreateOrUpdatePreparer(ctx context.Context, res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-08-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -167,7 +167,7 @@ func (client ElasticPoolsClient) DeletePreparer(ctx context.Context, resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-08-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -248,7 +248,7 @@ func (client ElasticPoolsClient) FailoverPreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-08-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -336,7 +336,7 @@ func (client ElasticPoolsClient) GetPreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-08-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -373,7 +373,7 @@ func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result Elast // from the Azure Resource Manager API or the portal. // serverName - the name of the server. // skip - the number of elements in the collection to skip. -func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultPage, err error) { +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int64) (result ElasticPoolListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") defer func() { @@ -412,14 +412,14 @@ func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroup } // ListByServerPreparer prepares the ListByServer request. -func (client ElasticPoolsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (*http.Request, error) { +func (client ElasticPoolsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, skip *int64) (*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 = "2020-11-01-preview" + const APIVersion = "2021-08-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -475,7 +475,7 @@ func (client ElasticPoolsClient) listByServerNextResults(ctx context.Context, la } // ListByServerComplete enumerates all values, automatically crossing page boundaries as required. -func (client ElasticPoolsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultIterator, err error) { +func (client ElasticPoolsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int64) (result ElasticPoolListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") defer func() { @@ -692,7 +692,7 @@ func (client ElasticPoolsClient) UpdatePreparer(ctx context.Context, resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-08-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/endpointcertificates.go b/services/preview/sql/mgmt/v5.0/sql/endpointcertificates.go new file mode 100644 index 000000000000..8ca9f8c7b43a --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/endpointcertificates.go @@ -0,0 +1,232 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// EndpointCertificatesClient 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 EndpointCertificatesClient struct { + BaseClient +} + +// NewEndpointCertificatesClient creates an instance of the EndpointCertificatesClient client. +func NewEndpointCertificatesClient(subscriptionID string) EndpointCertificatesClient { + return NewEndpointCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEndpointCertificatesClientWithBaseURI creates an instance of the EndpointCertificatesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewEndpointCertificatesClientWithBaseURI(baseURI string, subscriptionID string) EndpointCertificatesClient { + return EndpointCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a certificate used on the endpoint with the given id. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// endpointType - type of the endpoint whose certificate the customer is looking for. +func (client EndpointCertificatesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, endpointType string) (result EndpointCertificate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointCertificatesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, endpointType) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "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.EndpointCertificatesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EndpointCertificatesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, endpointType string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointType": autorest.Encode("path", endpointType), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/endpointCertificates/{endpointType}", 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 EndpointCertificatesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EndpointCertificatesClient) GetResponder(resp *http.Response) (result EndpointCertificate, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance list certificates used on endpoints on the target instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client EndpointCertificatesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result EndpointCertificateListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointCertificatesClient.ListByInstance") + defer func() { + sc := -1 + if result.eclr.Response.Response != nil { + sc = result.eclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.eclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.eclr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.eclr.hasNextLink() && result.eclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client EndpointCertificatesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/endpointCertificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client EndpointCertificatesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client EndpointCertificatesClient) ListByInstanceResponder(resp *http.Response) (result EndpointCertificateListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client EndpointCertificatesClient) listByInstanceNextResults(ctx context.Context, lastResults EndpointCertificateListResult) (result EndpointCertificateListResult, err error) { + req, err := lastResults.endpointCertificateListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EndpointCertificatesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client EndpointCertificatesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result EndpointCertificateListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointCertificatesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/enums.go b/services/preview/sql/mgmt/v5.0/sql/enums.go index d9231c128e95..0964ab73ee38 100644 --- a/services/preview/sql/mgmt/v5.0/sql/enums.go +++ b/services/preview/sql/mgmt/v5.0/sql/enums.go @@ -19,6 +19,23 @@ func PossibleAdministratorTypeValues() []AdministratorType { return []AdministratorType{AdministratorTypeActiveDirectory} } +// AdvancedThreatProtectionState enumerates the values for advanced threat protection state. +type AdvancedThreatProtectionState string + +const ( + // AdvancedThreatProtectionStateDisabled ... + AdvancedThreatProtectionStateDisabled AdvancedThreatProtectionState = "Disabled" + // AdvancedThreatProtectionStateEnabled ... + AdvancedThreatProtectionStateEnabled AdvancedThreatProtectionState = "Enabled" + // AdvancedThreatProtectionStateNew ... + AdvancedThreatProtectionStateNew AdvancedThreatProtectionState = "New" +) + +// PossibleAdvancedThreatProtectionStateValues returns an array of possible values for the AdvancedThreatProtectionState const type. +func PossibleAdvancedThreatProtectionStateValues() []AdvancedThreatProtectionState { + return []AdvancedThreatProtectionState{AdvancedThreatProtectionStateDisabled, AdvancedThreatProtectionStateEnabled, AdvancedThreatProtectionStateNew} +} + // AdvisorStatus enumerates the values for advisor status. type AdvisorStatus string @@ -213,6 +230,8 @@ type BackupStorageRedundancy string const ( // BackupStorageRedundancyGeo ... BackupStorageRedundancyGeo BackupStorageRedundancy = "Geo" + // BackupStorageRedundancyGeoZone ... + BackupStorageRedundancyGeoZone BackupStorageRedundancy = "GeoZone" // BackupStorageRedundancyLocal ... BackupStorageRedundancyLocal BackupStorageRedundancy = "Local" // BackupStorageRedundancyZone ... @@ -221,24 +240,7 @@ const ( // PossibleBackupStorageRedundancyValues returns an array of possible values for the BackupStorageRedundancy const type. func PossibleBackupStorageRedundancyValues() []BackupStorageRedundancy { - return []BackupStorageRedundancy{BackupStorageRedundancyGeo, BackupStorageRedundancyLocal, BackupStorageRedundancyZone} -} - -// BackupStorageRedundancy1 enumerates the values for backup storage redundancy 1. -type BackupStorageRedundancy1 string - -const ( - // BackupStorageRedundancy1Geo ... - BackupStorageRedundancy1Geo BackupStorageRedundancy1 = "Geo" - // BackupStorageRedundancy1Local ... - BackupStorageRedundancy1Local BackupStorageRedundancy1 = "Local" - // BackupStorageRedundancy1Zone ... - BackupStorageRedundancy1Zone BackupStorageRedundancy1 = "Zone" -) - -// PossibleBackupStorageRedundancy1Values returns an array of possible values for the BackupStorageRedundancy1 const type. -func PossibleBackupStorageRedundancy1Values() []BackupStorageRedundancy1 { - return []BackupStorageRedundancy1{BackupStorageRedundancy1Geo, BackupStorageRedundancy1Local, BackupStorageRedundancy1Zone} + return []BackupStorageRedundancy{BackupStorageRedundancyGeo, BackupStorageRedundancyGeoZone, BackupStorageRedundancyLocal, BackupStorageRedundancyZone} } // BlobAuditingPolicyState enumerates the values for blob auditing policy state. @@ -455,21 +457,19 @@ func PossibleCreateModeValues() []CreateMode { return []CreateMode{CreateModeCopy, CreateModeDefault, CreateModeOnlineSecondary, CreateModePointInTimeRestore, CreateModeRecovery, CreateModeRestore, CreateModeRestoreExternalBackup, CreateModeRestoreExternalBackupSecondary, CreateModeRestoreLongTermRetentionBackup, CreateModeSecondary} } -// CurrentBackupStorageRedundancy enumerates the values for current backup storage redundancy. -type CurrentBackupStorageRedundancy string +// DatabaseIdentityType enumerates the values for database identity type. +type DatabaseIdentityType string const ( - // CurrentBackupStorageRedundancyGeo ... - CurrentBackupStorageRedundancyGeo CurrentBackupStorageRedundancy = "Geo" - // CurrentBackupStorageRedundancyLocal ... - CurrentBackupStorageRedundancyLocal CurrentBackupStorageRedundancy = "Local" - // CurrentBackupStorageRedundancyZone ... - CurrentBackupStorageRedundancyZone CurrentBackupStorageRedundancy = "Zone" + // DatabaseIdentityTypeNone ... + DatabaseIdentityTypeNone DatabaseIdentityType = "None" + // DatabaseIdentityTypeUserAssigned ... + DatabaseIdentityTypeUserAssigned DatabaseIdentityType = "UserAssigned" ) -// PossibleCurrentBackupStorageRedundancyValues returns an array of possible values for the CurrentBackupStorageRedundancy const type. -func PossibleCurrentBackupStorageRedundancyValues() []CurrentBackupStorageRedundancy { - return []CurrentBackupStorageRedundancy{CurrentBackupStorageRedundancyGeo, CurrentBackupStorageRedundancyLocal, CurrentBackupStorageRedundancyZone} +// PossibleDatabaseIdentityTypeValues returns an array of possible values for the DatabaseIdentityType const type. +func PossibleDatabaseIdentityTypeValues() []DatabaseIdentityType { + return []DatabaseIdentityType{DatabaseIdentityTypeNone, DatabaseIdentityTypeUserAssigned} } // DatabaseLicenseType enumerates the values for database license type. @@ -563,13 +563,19 @@ const ( DatabaseStatusShutdown DatabaseStatus = "Shutdown" // DatabaseStatusStandby ... DatabaseStatusStandby DatabaseStatus = "Standby" + // DatabaseStatusStarting ... + DatabaseStatusStarting DatabaseStatus = "Starting" + // DatabaseStatusStopped ... + DatabaseStatusStopped DatabaseStatus = "Stopped" + // DatabaseStatusStopping ... + DatabaseStatusStopping DatabaseStatus = "Stopping" // DatabaseStatusSuspect ... DatabaseStatusSuspect DatabaseStatus = "Suspect" ) // PossibleDatabaseStatusValues returns an array of possible values for the DatabaseStatus const type. func PossibleDatabaseStatusValues() []DatabaseStatus { - return []DatabaseStatus{DatabaseStatusAutoClosed, DatabaseStatusCopying, DatabaseStatusCreating, DatabaseStatusDisabled, DatabaseStatusEmergencyMode, DatabaseStatusInaccessible, DatabaseStatusOffline, DatabaseStatusOfflineChangingDwPerformanceTiers, DatabaseStatusOfflineSecondary, DatabaseStatusOnline, DatabaseStatusOnlineChangingDwPerformanceTiers, DatabaseStatusPaused, DatabaseStatusPausing, DatabaseStatusRecovering, DatabaseStatusRecoveryPending, DatabaseStatusRestoring, DatabaseStatusResuming, DatabaseStatusScaling, DatabaseStatusShutdown, DatabaseStatusStandby, DatabaseStatusSuspect} + return []DatabaseStatus{DatabaseStatusAutoClosed, DatabaseStatusCopying, DatabaseStatusCreating, DatabaseStatusDisabled, DatabaseStatusEmergencyMode, DatabaseStatusInaccessible, DatabaseStatusOffline, DatabaseStatusOfflineChangingDwPerformanceTiers, DatabaseStatusOfflineSecondary, DatabaseStatusOnline, DatabaseStatusOnlineChangingDwPerformanceTiers, DatabaseStatusPaused, DatabaseStatusPausing, DatabaseStatusRecovering, DatabaseStatusRecoveryPending, DatabaseStatusRestoring, DatabaseStatusResuming, DatabaseStatusScaling, DatabaseStatusShutdown, DatabaseStatusStandby, DatabaseStatusStarting, DatabaseStatusStopped, DatabaseStatusStopping, DatabaseStatusSuspect} } // DataMaskingFunction enumerates the values for data masking function. @@ -720,13 +726,15 @@ const ( IdentityTypeNone IdentityType = "None" // IdentityTypeSystemAssigned ... IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + // IdentityTypeSystemAssignedUserAssigned ... + IdentityTypeSystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" // IdentityTypeUserAssigned ... IdentityTypeUserAssigned IdentityType = "UserAssigned" ) // PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. func PossibleIdentityTypeValues() []IdentityType { - return []IdentityType{IdentityTypeNone, IdentityTypeSystemAssigned, IdentityTypeUserAssigned} + return []IdentityType{IdentityTypeNone, IdentityTypeSystemAssigned, IdentityTypeSystemAssignedUserAssigned, IdentityTypeUserAssigned} } // ImplementationMethod enumerates the values for implementation method. @@ -1286,23 +1294,41 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ProvisioningState1 string const ( + // ProvisioningState1Accepted ... + ProvisioningState1Accepted ProvisioningState1 = "Accepted" + // ProvisioningState1Canceled ... + ProvisioningState1Canceled ProvisioningState1 = "Canceled" + // ProvisioningState1Created ... + ProvisioningState1Created ProvisioningState1 = "Created" // ProvisioningState1Creating ... ProvisioningState1Creating ProvisioningState1 = "Creating" + // ProvisioningState1Deleted ... + ProvisioningState1Deleted ProvisioningState1 = "Deleted" // ProvisioningState1Deleting ... ProvisioningState1Deleting ProvisioningState1 = "Deleting" // ProvisioningState1Failed ... ProvisioningState1Failed ProvisioningState1 = "Failed" + // ProvisioningState1NotSpecified ... + ProvisioningState1NotSpecified ProvisioningState1 = "NotSpecified" + // ProvisioningState1Registering ... + ProvisioningState1Registering ProvisioningState1 = "Registering" + // ProvisioningState1Running ... + ProvisioningState1Running ProvisioningState1 = "Running" // ProvisioningState1Succeeded ... ProvisioningState1Succeeded ProvisioningState1 = "Succeeded" + // ProvisioningState1TimedOut ... + ProvisioningState1TimedOut ProvisioningState1 = "TimedOut" // ProvisioningState1Unknown ... ProvisioningState1Unknown ProvisioningState1 = "Unknown" + // ProvisioningState1Unrecognized ... + ProvisioningState1Unrecognized ProvisioningState1 = "Unrecognized" // ProvisioningState1Updating ... ProvisioningState1Updating ProvisioningState1 = "Updating" ) // PossibleProvisioningState1Values returns an array of possible values for the ProvisioningState1 const type. func PossibleProvisioningState1Values() []ProvisioningState1 { - return []ProvisioningState1{ProvisioningState1Creating, ProvisioningState1Deleting, ProvisioningState1Failed, ProvisioningState1Succeeded, ProvisioningState1Unknown, ProvisioningState1Updating} + return []ProvisioningState1{ProvisioningState1Accepted, ProvisioningState1Canceled, ProvisioningState1Created, ProvisioningState1Creating, ProvisioningState1Deleted, ProvisioningState1Deleting, ProvisioningState1Failed, ProvisioningState1NotSpecified, ProvisioningState1Registering, ProvisioningState1Running, ProvisioningState1Succeeded, ProvisioningState1TimedOut, ProvisioningState1Unknown, ProvisioningState1Unrecognized, ProvisioningState1Updating} } // QueryMetricUnitType enumerates the values for query metric unit type. @@ -1453,6 +1479,21 @@ func PossibleReplicationLinkTypeValues() []ReplicationLinkType { return []ReplicationLinkType{ReplicationLinkTypeGEO, ReplicationLinkTypeNAMED} } +// ReplicationMode enumerates the values for replication mode. +type ReplicationMode string + +const ( + // ReplicationModeAsync ... + ReplicationModeAsync ReplicationMode = "Async" + // ReplicationModeSync ... + ReplicationModeSync ReplicationMode = "Sync" +) + +// PossibleReplicationModeValues returns an array of possible values for the ReplicationMode const type. +func PossibleReplicationModeValues() []ReplicationMode { + return []ReplicationMode{ReplicationModeAsync, ReplicationModeSync} +} + // ReplicationRole enumerates the values for replication role. type ReplicationRole string @@ -1508,23 +1549,6 @@ func PossibleReplicaTypeValues() []ReplicaType { return []ReplicaType{ReplicaTypePrimary, ReplicaTypeReadableSecondary} } -// RequestedBackupStorageRedundancy enumerates the values for requested backup storage redundancy. -type RequestedBackupStorageRedundancy string - -const ( - // RequestedBackupStorageRedundancyGeo ... - RequestedBackupStorageRedundancyGeo RequestedBackupStorageRedundancy = "Geo" - // RequestedBackupStorageRedundancyLocal ... - RequestedBackupStorageRedundancyLocal RequestedBackupStorageRedundancy = "Local" - // RequestedBackupStorageRedundancyZone ... - RequestedBackupStorageRedundancyZone RequestedBackupStorageRedundancy = "Zone" -) - -// PossibleRequestedBackupStorageRedundancyValues returns an array of possible values for the RequestedBackupStorageRedundancy const type. -func PossibleRequestedBackupStorageRedundancyValues() []RequestedBackupStorageRedundancy { - return []RequestedBackupStorageRedundancy{RequestedBackupStorageRedundancyGeo, RequestedBackupStorageRedundancyLocal, RequestedBackupStorageRedundancyZone} -} - // RestorePointType enumerates the values for restore point type. type RestorePointType string @@ -1875,6 +1899,21 @@ func PossibleServiceObjectiveNameValues() []ServiceObjectiveName { return []ServiceObjectiveName{ServiceObjectiveNameBasic, ServiceObjectiveNameDS100, ServiceObjectiveNameDS1000, ServiceObjectiveNameDS1200, ServiceObjectiveNameDS1500, ServiceObjectiveNameDS200, ServiceObjectiveNameDS2000, ServiceObjectiveNameDS300, ServiceObjectiveNameDS400, ServiceObjectiveNameDS500, ServiceObjectiveNameDS600, ServiceObjectiveNameDW100, ServiceObjectiveNameDW1000, ServiceObjectiveNameDW10000c, ServiceObjectiveNameDW1000c, ServiceObjectiveNameDW1200, ServiceObjectiveNameDW1500, ServiceObjectiveNameDW15000c, ServiceObjectiveNameDW1500c, ServiceObjectiveNameDW200, ServiceObjectiveNameDW2000, ServiceObjectiveNameDW2000c, ServiceObjectiveNameDW2500c, ServiceObjectiveNameDW300, ServiceObjectiveNameDW3000, ServiceObjectiveNameDW30000c, ServiceObjectiveNameDW3000c, ServiceObjectiveNameDW400, ServiceObjectiveNameDW500, ServiceObjectiveNameDW5000c, ServiceObjectiveNameDW600, ServiceObjectiveNameDW6000, ServiceObjectiveNameDW6000c, ServiceObjectiveNameDW7500c, ServiceObjectiveNameElasticPool, ServiceObjectiveNameFree, ServiceObjectiveNameP1, ServiceObjectiveNameP11, ServiceObjectiveNameP15, ServiceObjectiveNameP2, ServiceObjectiveNameP3, ServiceObjectiveNameP4, ServiceObjectiveNameP6, ServiceObjectiveNamePRS1, ServiceObjectiveNamePRS2, ServiceObjectiveNamePRS4, ServiceObjectiveNamePRS6, ServiceObjectiveNameS0, ServiceObjectiveNameS1, ServiceObjectiveNameS12, ServiceObjectiveNameS2, ServiceObjectiveNameS3, ServiceObjectiveNameS4, ServiceObjectiveNameS6, ServiceObjectiveNameS7, ServiceObjectiveNameS9, ServiceObjectiveNameSystem, ServiceObjectiveNameSystem0, ServiceObjectiveNameSystem1, ServiceObjectiveNameSystem2, ServiceObjectiveNameSystem2L, ServiceObjectiveNameSystem3, ServiceObjectiveNameSystem3L, ServiceObjectiveNameSystem4, ServiceObjectiveNameSystem4L} } +// ServicePrincipalType enumerates the values for service principal type. +type ServicePrincipalType string + +const ( + // ServicePrincipalTypeNone ... + ServicePrincipalTypeNone ServicePrincipalType = "None" + // ServicePrincipalTypeSystemAssigned ... + ServicePrincipalTypeSystemAssigned ServicePrincipalType = "SystemAssigned" +) + +// PossibleServicePrincipalTypeValues returns an array of possible values for the ServicePrincipalType const type. +func PossibleServicePrincipalTypeValues() []ServicePrincipalType { + return []ServicePrincipalType{ServicePrincipalTypeNone, ServicePrincipalTypeSystemAssigned} +} + // State enumerates the values for state. type State string @@ -1945,23 +1984,6 @@ func PossibleStorageAccountTypeValues() []StorageAccountType { return []StorageAccountType{StorageAccountTypeGRS, StorageAccountTypeLRS, StorageAccountTypeZRS} } -// StorageAccountType1 enumerates the values for storage account type 1. -type StorageAccountType1 string - -const ( - // StorageAccountType1GRS ... - StorageAccountType1GRS StorageAccountType1 = "GRS" - // StorageAccountType1LRS ... - StorageAccountType1LRS StorageAccountType1 = "LRS" - // StorageAccountType1ZRS ... - StorageAccountType1ZRS StorageAccountType1 = "ZRS" -) - -// PossibleStorageAccountType1Values returns an array of possible values for the StorageAccountType1 const type. -func PossibleStorageAccountType1Values() []StorageAccountType1 { - return []StorageAccountType1{StorageAccountType1GRS, StorageAccountType1LRS, StorageAccountType1ZRS} -} - // StorageKeyType enumerates the values for storage key type. type StorageKeyType string @@ -2066,6 +2088,25 @@ func PossibleSyncGroupStateValues() []SyncGroupState { return []SyncGroupState{SyncGroupStateError, SyncGroupStateGood, SyncGroupStateNotReady, SyncGroupStateProgressing, SyncGroupStateWarning} } +// SyncGroupsType enumerates the values for sync groups type. +type SyncGroupsType string + +const ( + // SyncGroupsTypeAll ... + SyncGroupsTypeAll SyncGroupsType = "All" + // SyncGroupsTypeError ... + SyncGroupsTypeError SyncGroupsType = "Error" + // SyncGroupsTypeSuccess ... + SyncGroupsTypeSuccess SyncGroupsType = "Success" + // SyncGroupsTypeWarning ... + SyncGroupsTypeWarning SyncGroupsType = "Warning" +) + +// PossibleSyncGroupsTypeValues returns an array of possible values for the SyncGroupsType const type. +func PossibleSyncGroupsTypeValues() []SyncGroupsType { + return []SyncGroupsType{SyncGroupsTypeAll, SyncGroupsTypeError, SyncGroupsTypeSuccess, SyncGroupsTypeWarning} +} + // SyncMemberDbType enumerates the values for sync member db type. type SyncMemberDbType string @@ -2145,39 +2186,6 @@ func PossibleTableTemporalTypeValues() []TableTemporalType { return []TableTemporalType{TableTemporalTypeHistoryTable, TableTemporalTypeNonTemporalTable, TableTemporalTypeSystemVersionedTemporalTable} } -// TargetBackupStorageRedundancy enumerates the values for target backup storage redundancy. -type TargetBackupStorageRedundancy string - -const ( - // TargetBackupStorageRedundancyGeo ... - TargetBackupStorageRedundancyGeo TargetBackupStorageRedundancy = "Geo" - // TargetBackupStorageRedundancyLocal ... - TargetBackupStorageRedundancyLocal TargetBackupStorageRedundancy = "Local" - // TargetBackupStorageRedundancyZone ... - TargetBackupStorageRedundancyZone TargetBackupStorageRedundancy = "Zone" -) - -// PossibleTargetBackupStorageRedundancyValues returns an array of possible values for the TargetBackupStorageRedundancy const type. -func PossibleTargetBackupStorageRedundancyValues() []TargetBackupStorageRedundancy { - return []TargetBackupStorageRedundancy{TargetBackupStorageRedundancyGeo, TargetBackupStorageRedundancyLocal, TargetBackupStorageRedundancyZone} -} - -// TransparentDataEncryptionActivityStatus enumerates the values for transparent data encryption activity -// status. -type TransparentDataEncryptionActivityStatus string - -const ( - // TransparentDataEncryptionActivityStatusDecrypting ... - TransparentDataEncryptionActivityStatusDecrypting TransparentDataEncryptionActivityStatus = "Decrypting" - // TransparentDataEncryptionActivityStatusEncrypting ... - TransparentDataEncryptionActivityStatusEncrypting TransparentDataEncryptionActivityStatus = "Encrypting" -) - -// PossibleTransparentDataEncryptionActivityStatusValues returns an array of possible values for the TransparentDataEncryptionActivityStatus const type. -func PossibleTransparentDataEncryptionActivityStatusValues() []TransparentDataEncryptionActivityStatus { - return []TransparentDataEncryptionActivityStatus{TransparentDataEncryptionActivityStatusDecrypting, TransparentDataEncryptionActivityStatusEncrypting} -} - // TransparentDataEncryptionState enumerates the values for transparent data encryption state. type TransparentDataEncryptionState string @@ -2193,21 +2201,6 @@ func PossibleTransparentDataEncryptionStateValues() []TransparentDataEncryptionS return []TransparentDataEncryptionState{TransparentDataEncryptionStateDisabled, TransparentDataEncryptionStateEnabled} } -// TransparentDataEncryptionStatus enumerates the values for transparent data encryption status. -type TransparentDataEncryptionStatus string - -const ( - // TransparentDataEncryptionStatusDisabled ... - TransparentDataEncryptionStatusDisabled TransparentDataEncryptionStatus = "Disabled" - // TransparentDataEncryptionStatusEnabled ... - TransparentDataEncryptionStatusEnabled TransparentDataEncryptionStatus = "Enabled" -) - -// PossibleTransparentDataEncryptionStatusValues returns an array of possible values for the TransparentDataEncryptionStatus const type. -func PossibleTransparentDataEncryptionStatusValues() []TransparentDataEncryptionStatus { - return []TransparentDataEncryptionStatus{TransparentDataEncryptionStatusDisabled, TransparentDataEncryptionStatusEnabled} -} - // UnitDefinitionType enumerates the values for unit definition type. type UnitDefinitionType string diff --git a/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go index 31fbb81916b2..309c2f97b22d 100644 --- a/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go @@ -84,7 +84,7 @@ func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer( "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -166,7 +166,7 @@ func (client ExtendedDatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -250,7 +250,7 @@ func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer( "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go index 40e3f86e3799..fdd90e55aa99 100644 --- a/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go @@ -75,7 +75,7 @@ func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ct "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -165,7 +165,7 @@ func (client ExtendedServerBlobAuditingPoliciesClient) GetPreparer(ctx context.C "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -247,7 +247,7 @@ func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerPreparer(ctx "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/ipv6firewallrules.go b/services/preview/sql/mgmt/v5.0/sql/ipv6firewallrules.go new file mode 100644 index 000000000000..7bb7c5c21f54 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/ipv6firewallrules.go @@ -0,0 +1,392 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// IPv6FirewallRulesClient 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 IPv6FirewallRulesClient struct { + BaseClient +} + +// NewIPv6FirewallRulesClient creates an instance of the IPv6FirewallRulesClient client. +func NewIPv6FirewallRulesClient(subscriptionID string) IPv6FirewallRulesClient { + return NewIPv6FirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIPv6FirewallRulesClientWithBaseURI creates an instance of the IPv6FirewallRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewIPv6FirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) IPv6FirewallRulesClient { + return IPv6FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an IPv6 firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +// parameters - the required parameters for creating or updating an IPv6 firewall rule. +func (client IPv6FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters IPv6FirewallRule) (result IPv6FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "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.IPv6FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IPv6FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters IPv6FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}", 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 IPv6FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IPv6FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result IPv6FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an IPv6 firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client IPv6FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IPv6FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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}/ipv6FirewallRules/{firewallRuleName}", 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 IPv6FirewallRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IPv6FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an IPv6 firewall rule. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client IPv6FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result IPv6FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "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.IPv6FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IPv6FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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}/ipv6FirewallRules/{firewallRuleName}", 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 IPv6FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IPv6FirewallRulesClient) GetResponder(resp *http.Response) (result IPv6FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of IPv6 firewall rules. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client IPv6FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result IPv6FirewallRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.ip6frlr.Response.Response != nil { + sc = result.ip6frlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ip6frlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ip6frlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ip6frlr.hasNextLink() && result.ip6frlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client IPv6FirewallRulesClient) 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 = "2021-11-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}/ipv6FirewallRules", 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 IPv6FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client IPv6FirewallRulesClient) ListByServerResponder(resp *http.Response) (result IPv6FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + 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 IPv6FirewallRulesClient) listByServerNextResults(ctx context.Context, lastResults IPv6FirewallRuleListResult) (result IPv6FirewallRuleListResult, err error) { + req, err := lastResults.iPv6FirewallRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "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.IPv6FirewallRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.IPv6FirewallRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client IPv6FirewallRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result IPv6FirewallRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go b/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go index c5103a6ca454..c758e79ad4b4 100644 --- a/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go +++ b/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go @@ -39,13 +39,13 @@ func NewLedgerDigestUploadsClientWithBaseURI(baseURI string, subscriptionID stri // from the Azure Resource Manager API or the portal. // serverName - the name of the server. // databaseName - the name of the database. -func (client LedgerDigestUploadsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LedgerDigestUploads) (result LedgerDigestUploads, err error) { +func (client LedgerDigestUploadsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LedgerDigestUploads) (result LedgerDigestUploadsCreateOrUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.CreateOrUpdate") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -56,16 +56,9 @@ func (client LedgerDigestUploadsClient) CreateOrUpdate(ctx context.Context, reso return } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) + result, err = client.CreateOrUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "CreateOrUpdate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } @@ -99,8 +92,18 @@ func (client LedgerDigestUploadsClient) CreateOrUpdatePreparer(ctx context.Conte // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client LedgerDigestUploadsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client LedgerDigestUploadsClient) CreateOrUpdateSender(req *http.Request) (future LedgerDigestUploadsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return } // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always @@ -121,13 +124,13 @@ func (client LedgerDigestUploadsClient) CreateOrUpdateResponder(resp *http.Respo // from the Azure Resource Manager API or the portal. // serverName - the name of the server. // databaseName - the name of the database. -func (client LedgerDigestUploadsClient) Disable(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LedgerDigestUploads, err error) { +func (client LedgerDigestUploadsClient) Disable(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LedgerDigestUploadsDisableFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.Disable") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -138,16 +141,9 @@ func (client LedgerDigestUploadsClient) Disable(ctx context.Context, resourceGro return } - resp, err := client.DisableSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Disable", resp, "Failure sending request") - return - } - - result, err = client.DisableResponder(resp) + result, err = client.DisableSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Disable", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Disable", result.Response(), "Failure sending request") return } @@ -179,8 +175,18 @@ func (client LedgerDigestUploadsClient) DisablePreparer(ctx context.Context, res // DisableSender sends the Disable request. The method will close the // http.Response Body if it receives an error. -func (client LedgerDigestUploadsClient) DisableSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client LedgerDigestUploadsClient) DisableSender(req *http.Request) (future LedgerDigestUploadsDisableFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return } // DisableResponder handles the response to the Disable request. The method always diff --git a/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go b/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go index 99ca55b9bef1..34221dfe6b02 100644 --- a/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go +++ b/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go @@ -76,7 +76,7 @@ func (client LongTermRetentionBackupsClient) CopyPreparer(ctx context.Context, l "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -165,7 +165,7 @@ func (client LongTermRetentionBackupsClient) CopyByResourceGroupPreparer(ctx con "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -250,7 +250,7 @@ func (client LongTermRetentionBackupsClient) DeletePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -335,7 +335,7 @@ func (client LongTermRetentionBackupsClient) DeleteByResourceGroupPreparer(ctx c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -424,7 +424,7 @@ func (client LongTermRetentionBackupsClient) GetPreparer(ctx context.Context, lo "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -507,7 +507,7 @@ func (client LongTermRetentionBackupsClient) GetByResourceGroupPreparer(ctx cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -592,7 +592,7 @@ func (client LongTermRetentionBackupsClient) ListByDatabasePreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -716,7 +716,7 @@ func (client LongTermRetentionBackupsClient) ListByLocationPreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -847,7 +847,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabasePreparer "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -974,7 +974,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationPreparer "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1103,7 +1103,7 @@ func (client LongTermRetentionBackupsClient) ListByResourceGroupServerPreparer(c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1229,7 +1229,7 @@ func (client LongTermRetentionBackupsClient) ListByServerPreparer(ctx context.Co "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1346,7 +1346,7 @@ func (client LongTermRetentionBackupsClient) UpdatePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1435,7 +1435,7 @@ func (client LongTermRetentionBackupsClient) UpdateByResourceGroupPreparer(ctx c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go b/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go index f9cde4f9388e..a3bbf78627ef 100644 --- a/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go +++ b/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go @@ -76,7 +76,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) DeletePreparer(ctx c "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -161,7 +161,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -250,7 +250,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) GetPreparer(ctx cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -333,7 +333,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupPr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -418,7 +418,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabasePrepar "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -544,7 +544,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstancePrepar "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -668,7 +668,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationPrepar "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -799,7 +799,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupD "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -928,7 +928,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupI "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1055,7 +1055,7 @@ func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupL "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go index dfd1380ebc88..b52b859cd667 100644 --- a/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go @@ -80,7 +80,7 @@ func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdatePreparer( "databaseName": autorest.Encode("path", databaseName), "managedInstanceName": autorest.Encode("path", managedInstanceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), - "securityAlertPolicyName": autorest.Encode("path", "default"), + "securityAlertPolicyName": autorest.Encode("path", "Default"), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } @@ -162,7 +162,7 @@ func (client ManagedDatabaseSecurityAlertPoliciesClient) GetPreparer(ctx context "databaseName": autorest.Encode("path", databaseName), "managedInstanceName": autorest.Encode("path", managedInstanceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), - "securityAlertPolicyName": autorest.Encode("path", "default"), + "securityAlertPolicyName": autorest.Encode("path", "Default"), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstances.go b/services/preview/sql/mgmt/v5.0/sql/managedinstances.go index 6cd74238340c..a8d719b66602 100644 --- a/services/preview/sql/mgmt/v5.0/sql/managedinstances.go +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstances.go @@ -81,7 +81,7 @@ func (client ManagedInstancesClient) CreateOrUpdatePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -163,7 +163,7 @@ func (client ManagedInstancesClient) DeletePreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -243,7 +243,7 @@ func (client ManagedInstancesClient) FailoverPreparer(ctx context.Context, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -333,7 +333,7 @@ func (client ManagedInstancesClient) GetPreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -414,7 +414,7 @@ func (client ManagedInstancesClient) ListPreparer(ctx context.Context, expand st "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -537,7 +537,7 @@ func (client ManagedInstancesClient) ListByInstancePoolPreparer(ctx context.Cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -667,7 +667,7 @@ func (client ManagedInstancesClient) ListByManagedInstancePreparer(ctx context.C "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -806,7 +806,7 @@ func (client ManagedInstancesClient) ListByResourceGroupPreparer(ctx context.Con "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -917,7 +917,7 @@ func (client ManagedInstancesClient) UpdatePreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/managedserverdnsaliases.go b/services/preview/sql/mgmt/v5.0/sql/managedserverdnsaliases.go new file mode 100644 index 000000000000..0586ca33398b --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedserverdnsaliases.go @@ -0,0 +1,484 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedServerDNSAliasesClient 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 ManagedServerDNSAliasesClient struct { + BaseClient +} + +// NewManagedServerDNSAliasesClient creates an instance of the ManagedServerDNSAliasesClient client. +func NewManagedServerDNSAliasesClient(subscriptionID string) ManagedServerDNSAliasesClient { + return NewManagedServerDNSAliasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedServerDNSAliasesClientWithBaseURI creates an instance of the ManagedServerDNSAliasesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewManagedServerDNSAliasesClientWithBaseURI(baseURI string, subscriptionID string) ManagedServerDNSAliasesClient { + return ManagedServerDNSAliasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Acquire acquires managed server DNS alias from another managed server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerDNSAliasesClient) Acquire(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string, parameters ManagedServerDNSAliasAcquisition) (result ManagedServerDNSAliasesAcquireFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasesClient.Acquire") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.OldManagedServerDNSAliasResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ManagedServerDNSAliasesClient", "Acquire", err.Error()) + } + + req, err := client.AcquirePreparer(ctx, resourceGroupName, managedInstanceName, DNSAliasName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "Acquire", nil, "Failure preparing request") + return + } + + result, err = client.AcquireSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "Acquire", result.Response(), "Failure sending request") + return + } + + return +} + +// AcquirePreparer prepares the Acquire request. +func (client ManagedServerDNSAliasesClient) AcquirePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string, parameters ManagedServerDNSAliasAcquisition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}/acquire", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AcquireSender sends the Acquire request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedServerDNSAliasesClient) AcquireSender(req *http.Request) (future ManagedServerDNSAliasesAcquireFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// AcquireResponder handles the response to the Acquire request. The method always +// closes the http.Response Body. +func (client ManagedServerDNSAliasesClient) AcquireResponder(resp *http.Response) (result ManagedServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates a managed server DNS alias. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerDNSAliasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string, parameters ManagedServerDNSAliasCreation) (result ManagedServerDNSAliasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, DNSAliasName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedServerDNSAliasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string, parameters ManagedServerDNSAliasCreation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}", 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 ManagedServerDNSAliasesClient) CreateOrUpdateSender(req *http.Request) (future ManagedServerDNSAliasesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedServerDNSAliasesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed server DNS alias with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerDNSAliasesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string) (result ManagedServerDNSAliasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedServerDNSAliasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}", 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 ManagedServerDNSAliasesClient) DeleteSender(req *http.Request) (future ManagedServerDNSAliasesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedServerDNSAliasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server DNS alias. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerDNSAliasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string) (result ManagedServerDNSAlias, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "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.ManagedServerDNSAliasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedServerDNSAliasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}", 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 ManagedServerDNSAliasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedServerDNSAliasesClient) GetResponder(resp *http.Response) (result ManagedServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedInstance gets a list of managed server DNS aliases for a managed server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerDNSAliasesClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerDNSAliasListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.msdalr.Response.Response != nil { + sc = result.msdalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.msdalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.msdalr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.msdalr.hasNextLink() && result.msdalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedServerDNSAliasesClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/dnsAliases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedServerDNSAliasesClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedServerDNSAliasesClient) ListByManagedInstanceResponder(resp *http.Response) (result ManagedServerDNSAliasListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedServerDNSAliasesClient) listByManagedInstanceNextResults(ctx context.Context, lastResults ManagedServerDNSAliasListResult) (result ManagedServerDNSAliasListResult, err error) { + req, err := lastResults.managedServerDNSAliasListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedServerDNSAliasesClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerDNSAliasListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/models.go b/services/preview/sql/mgmt/v5.0/sql/models.go index 32af3e49022d..2d0901278638 100644 --- a/services/preview/sql/mgmt/v5.0/sql/models.go +++ b/services/preview/sql/mgmt/v5.0/sql/models.go @@ -219,6 +219,23 @@ func (ap AdministratorProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// AdvancedThreatProtectionProperties properties of an Advanced Threat Protection state. +type AdvancedThreatProtectionProperties struct { + // State - Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific database or server. Possible values include: 'AdvancedThreatProtectionStateNew', 'AdvancedThreatProtectionStateEnabled', 'AdvancedThreatProtectionStateDisabled' + State AdvancedThreatProtectionState `json:"state,omitempty"` + // CreationTime - READ-ONLY; Specifies the UTC creation time of the policy. + CreationTime *date.Time `json:"creationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdvancedThreatProtectionProperties. +func (atpp AdvancedThreatProtectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atpp.State != "" { + objectMap["state"] = atpp.State + } + return json.Marshal(objectMap) +} + // Advisor database, Server or Elastic Pool Advisor. type Advisor struct { autorest.Response `json:"-"` @@ -1106,8 +1123,8 @@ type CopyLongTermRetentionBackupParametersProperties struct { TargetServerFullyQualifiedDomainName *string `json:"targetServerFullyQualifiedDomainName,omitempty"` // TargetDatabaseName - The name of the database owns the copied backup. TargetDatabaseName *string `json:"targetDatabaseName,omitempty"` - // TargetBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'TargetBackupStorageRedundancyGeo', 'TargetBackupStorageRedundancyLocal', 'TargetBackupStorageRedundancyZone' - TargetBackupStorageRedundancy TargetBackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` + // TargetBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + TargetBackupStorageRedundancy BackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` } // CreateDatabaseRestorePointDefinition contains the information necessary to perform a create database @@ -1136,6 +1153,8 @@ type Database struct { Kind *string `json:"kind,omitempty"` // ManagedBy - READ-ONLY; Resource that manages the database. ManagedBy *string `json:"managedBy,omitempty"` + // Identity - The Azure Active Directory identity of the database. + Identity *DatabaseIdentity `json:"identity,omitempty"` // DatabaseProperties - Resource properties. *DatabaseProperties `json:"properties,omitempty"` // Location - Resource location. @@ -1156,6 +1175,9 @@ func (d Database) MarshalJSON() ([]byte, error) { if d.Sku != nil { objectMap["sku"] = d.Sku } + if d.Identity != nil { + objectMap["identity"] = d.Identity + } if d.DatabaseProperties != nil { objectMap["properties"] = d.DatabaseProperties } @@ -1204,6 +1226,15 @@ func (d *Database) UnmarshalJSON(body []byte) error { } d.ManagedBy = &managedBy } + case "identity": + if v != nil { + var identity DatabaseIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + d.Identity = &identity + } case "properties": if v != nil { var databaseProperties DatabaseProperties @@ -1264,6 +1295,258 @@ func (d *Database) UnmarshalJSON(body []byte) error { return nil } +// DatabaseAdvancedThreatProtection a database Advanced Threat Protection. +type DatabaseAdvancedThreatProtection struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of AdvancedThreatProtectionResource. + SystemData *SystemData `json:"systemData,omitempty"` + // AdvancedThreatProtectionProperties - Resource properties. + *AdvancedThreatProtectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAdvancedThreatProtection. +func (datp DatabaseAdvancedThreatProtection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if datp.AdvancedThreatProtectionProperties != nil { + objectMap["properties"] = datp.AdvancedThreatProtectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAdvancedThreatProtection struct. +func (datp *DatabaseAdvancedThreatProtection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + datp.SystemData = &systemData + } + case "properties": + if v != nil { + var advancedThreatProtectionProperties AdvancedThreatProtectionProperties + err = json.Unmarshal(*v, &advancedThreatProtectionProperties) + if err != nil { + return err + } + datp.AdvancedThreatProtectionProperties = &advancedThreatProtectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + datp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + datp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + datp.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseAdvancedThreatProtectionListResult a list of the database's Advanced Threat Protection +// configurations. +type DatabaseAdvancedThreatProtectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseAdvancedThreatProtection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAdvancedThreatProtectionListResult. +func (datplr DatabaseAdvancedThreatProtectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseAdvancedThreatProtectionListResultIterator provides access to a complete listing of +// DatabaseAdvancedThreatProtection values. +type DatabaseAdvancedThreatProtectionListResultIterator struct { + i int + page DatabaseAdvancedThreatProtectionListResultPage +} + +// NextWithContext 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 *DatabaseAdvancedThreatProtectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvancedThreatProtectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseAdvancedThreatProtectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseAdvancedThreatProtectionListResultIterator) 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 DatabaseAdvancedThreatProtectionListResultIterator) Response() DatabaseAdvancedThreatProtectionListResult { + 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 DatabaseAdvancedThreatProtectionListResultIterator) Value() DatabaseAdvancedThreatProtection { + if !iter.page.NotDone() { + return DatabaseAdvancedThreatProtection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseAdvancedThreatProtectionListResultIterator type. +func NewDatabaseAdvancedThreatProtectionListResultIterator(page DatabaseAdvancedThreatProtectionListResultPage) DatabaseAdvancedThreatProtectionListResultIterator { + return DatabaseAdvancedThreatProtectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (datplr DatabaseAdvancedThreatProtectionListResult) IsEmpty() bool { + return datplr.Value == nil || len(*datplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (datplr DatabaseAdvancedThreatProtectionListResult) hasNextLink() bool { + return datplr.NextLink != nil && len(*datplr.NextLink) != 0 +} + +// databaseAdvancedThreatProtectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (datplr DatabaseAdvancedThreatProtectionListResult) databaseAdvancedThreatProtectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !datplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(datplr.NextLink))) +} + +// DatabaseAdvancedThreatProtectionListResultPage contains a page of DatabaseAdvancedThreatProtection +// values. +type DatabaseAdvancedThreatProtectionListResultPage struct { + fn func(context.Context, DatabaseAdvancedThreatProtectionListResult) (DatabaseAdvancedThreatProtectionListResult, error) + datplr DatabaseAdvancedThreatProtectionListResult +} + +// NextWithContext 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 *DatabaseAdvancedThreatProtectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvancedThreatProtectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.datplr) + if err != nil { + return err + } + page.datplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseAdvancedThreatProtectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseAdvancedThreatProtectionListResultPage) NotDone() bool { + return !page.datplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseAdvancedThreatProtectionListResultPage) Response() DatabaseAdvancedThreatProtectionListResult { + return page.datplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseAdvancedThreatProtectionListResultPage) Values() []DatabaseAdvancedThreatProtection { + if page.datplr.IsEmpty() { + return nil + } + return *page.datplr.Value +} + +// Creates a new instance of the DatabaseAdvancedThreatProtectionListResultPage type. +func NewDatabaseAdvancedThreatProtectionListResultPage(cur DatabaseAdvancedThreatProtectionListResult, getNextPage func(context.Context, DatabaseAdvancedThreatProtectionListResult) (DatabaseAdvancedThreatProtectionListResult, error)) DatabaseAdvancedThreatProtectionListResultPage { + return DatabaseAdvancedThreatProtectionListResultPage{ + fn: getNextPage, + datplr: cur, + } +} + // DatabaseAutomaticTuning database-level Automatic Tuning. type DatabaseAutomaticTuning struct { autorest.Response `json:"-"` @@ -1645,6 +1928,10 @@ type DatabaseBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // LEDGER_OPERATION_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -1688,6 +1975,8 @@ type DatabaseBlobAuditingPolicyProperties struct { // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // IsManagedIdentityInUse - Specifies whether Managed Identity is used to access blob storage + IsManagedIdentityInUse *bool `json:"isManagedIdentityInUse,omitempty"` // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' State BlobAuditingPolicyState `json:"state,omitempty"` // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. @@ -2080,6 +2369,28 @@ type DatabaseExtensionsProperties struct { StorageURI *string `json:"storageUri,omitempty"` } +// DatabaseIdentity azure Active Directory identity configuration for a resource. +type DatabaseIdentity struct { + // Type - The identity type. Possible values include: 'DatabaseIdentityTypeNone', 'DatabaseIdentityTypeUserAssigned' + Type DatabaseIdentityType `json:"type,omitempty"` + // TenantID - READ-ONLY; The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // UserAssignedIdentities - The resource ids of the user assigned identities to use + UserAssignedIdentities map[string]*DatabaseUserIdentity `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for DatabaseIdentity. +func (di DatabaseIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if di.Type != "" { + objectMap["type"] = di.Type + } + if di.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = di.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + // DatabaseListResult a list of databases. type DatabaseListResult struct { autorest.Response `json:"-"` @@ -2550,7 +2861,7 @@ type DatabaseProperties struct { ElasticPoolID *string `json:"elasticPoolId,omitempty"` // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` - // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled' + // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled', 'DatabaseStatusStopping', 'DatabaseStatusStopped', 'DatabaseStatusStarting' Status DatabaseStatus `json:"status,omitempty"` // DatabaseID - READ-ONLY; The ID of the database. DatabaseID *uuid.UUID `json:"databaseId,omitempty"` @@ -2586,9 +2897,9 @@ type DatabaseProperties struct { MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` - // ReadScale - The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' + // ReadScale - The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' ReadScale DatabaseReadScale `json:"readScale,omitempty"` - // HighAvailabilityReplicaCount - The number of secondary replicas associated with the database that are used to provide high availability. + // HighAvailabilityReplicaCount - The number of secondary replicas associated with the database that are used to provide high availability. Not applicable to a Hyperscale database within an elastic pool. HighAvailabilityReplicaCount *int32 `json:"highAvailabilityReplicaCount,omitempty"` // SecondaryType - The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: 'SecondaryTypeGeo', 'SecondaryTypeNamed' SecondaryType SecondaryType `json:"secondaryType,omitempty"` @@ -2596,10 +2907,10 @@ type DatabaseProperties struct { CurrentSku *Sku `json:"currentSku,omitempty"` // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` - // CurrentBackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'CurrentBackupStorageRedundancyGeo', 'CurrentBackupStorageRedundancyLocal', 'CurrentBackupStorageRedundancyZone' - CurrentBackupStorageRedundancy CurrentBackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` - // RequestedBackupStorageRedundancy - The storage account type to be used to store backups for this database. Possible values include: 'RequestedBackupStorageRedundancyGeo', 'RequestedBackupStorageRedundancyLocal', 'RequestedBackupStorageRedundancyZone' - RequestedBackupStorageRedundancy RequestedBackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` + // CurrentBackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + CurrentBackupStorageRedundancy BackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage account type to be used to store backups for this database. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` // MinCapacity - Minimal capacity that database will always have allocated, if not paused MinCapacity *float64 `json:"minCapacity,omitempty"` // PausedDate - READ-ONLY; The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. @@ -2612,6 +2923,22 @@ type DatabaseProperties struct { IsLedgerOn *bool `json:"isLedgerOn,omitempty"` // IsInfraEncryptionEnabled - READ-ONLY; Infra encryption is enabled for this database. IsInfraEncryptionEnabled *bool `json:"isInfraEncryptionEnabled,omitempty"` + // FederatedClientID - The Client id used for cross tenant per database CMK scenario + FederatedClientID *uuid.UUID `json:"federatedClientId,omitempty"` + // SourceResourceID - The resource identifier of the source associated with the create operation of this database. + // + // When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode must be PointInTimeRestore, Restore or Recover. + // + // When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of an existing database or existing sql pool, and restorePointInTime must be specified. + // + // When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped database or restorable dropped sql pool. + // + // When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or recoverable sql pool. + // + // This property allows to restore across subscriptions which is only supported for DataWarehouse edition. + // + // When source subscription belongs to a different tenant than target subscription, “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. For more details about “x-ms-authorization-auxiliary” header see https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant + SourceResourceID *string `json:"sourceResourceId,omitempty"` } // MarshalJSON is the custom marshaler for DatabaseProperties. @@ -2686,6 +3013,12 @@ func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { if dp.IsLedgerOn != nil { objectMap["isLedgerOn"] = dp.IsLedgerOn } + if dp.FederatedClientID != nil { + objectMap["federatedClientId"] = dp.FederatedClientID + } + if dp.SourceResourceID != nil { + objectMap["sourceResourceId"] = dp.SourceResourceID + } return json.Marshal(objectMap) } @@ -3736,12 +4069,14 @@ type DatabaseTableProperties struct { MemoryOptimized *bool `json:"memoryOptimized,omitempty"` } -// DatabaseUpdate a database resource. +// DatabaseUpdate a database update resource. type DatabaseUpdate struct { // Sku - The name and tier of the SKU. Sku *Sku `json:"sku,omitempty"` - // DatabaseProperties - Resource properties. - *DatabaseProperties `json:"properties,omitempty"` + // Identity - Database identity + Identity *DatabaseIdentity `json:"identity,omitempty"` + // DatabaseUpdateProperties - Resource properties. + *DatabaseUpdateProperties `json:"properties,omitempty"` // Tags - Resource tags. Tags map[string]*string `json:"tags"` } @@ -3752,8 +4087,11 @@ func (du DatabaseUpdate) MarshalJSON() ([]byte, error) { if du.Sku != nil { objectMap["sku"] = du.Sku } - if du.DatabaseProperties != nil { - objectMap["properties"] = du.DatabaseProperties + if du.Identity != nil { + objectMap["identity"] = du.Identity + } + if du.DatabaseUpdateProperties != nil { + objectMap["properties"] = du.DatabaseUpdateProperties } if du.Tags != nil { objectMap["tags"] = du.Tags @@ -3779,14 +4117,23 @@ func (du *DatabaseUpdate) UnmarshalJSON(body []byte) error { } du.Sku = &sku } + case "identity": + if v != nil { + var identity DatabaseIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + du.Identity = &identity + } case "properties": if v != nil { - var databaseProperties DatabaseProperties - err = json.Unmarshal(*v, &databaseProperties) + var databaseUpdateProperties DatabaseUpdateProperties + err = json.Unmarshal(*v, &databaseUpdateProperties) if err != nil { return err } - du.DatabaseProperties = &databaseProperties + du.DatabaseUpdateProperties = &databaseUpdateProperties } case "tags": if v != nil { @@ -3803,25 +4150,199 @@ func (du *DatabaseUpdate) UnmarshalJSON(body []byte) error { return nil } -// DatabaseUsage usage metric of a database. -type DatabaseUsage struct { - // DatabaseUsageProperties - Resource properties. - *DatabaseUsageProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseUsage. -func (du DatabaseUsage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if du.DatabaseUsageProperties != nil { - objectMap["properties"] = du.DatabaseUsageProperties - } - return json.Marshal(objectMap) +// DatabaseUpdateProperties a database update properties. +type DatabaseUpdateProperties struct { + // CreateMode - Specifies the mode of database creation. + // + // Default: regular database creation. + // + // Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database. + // + // Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database. + // + // PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified. + // + // 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, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'CreateModeDefault', 'CreateModeCopy', 'CreateModeSecondary', 'CreateModePointInTimeRestore', 'CreateModeRestore', 'CreateModeRecovery', 'CreateModeRestoreExternalBackup', 'CreateModeRestoreExternalBackupSecondary', 'CreateModeRestoreLongTermRetentionBackup', 'CreateModeOnlineSecondary' + CreateMode CreateMode `json:"createMode,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` + // MaxSizeBytes - The max size of the database expressed in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // SampleName - The name of the sample schema to apply when creating this database. Possible values include: 'SampleNameAdventureWorksLT', 'SampleNameWideWorldImportersStd', 'SampleNameWideWorldImportersFull' + SampleName SampleName `json:"sampleName,omitempty"` + // ElasticPoolID - The resource identifier of the elastic pool containing this database. + ElasticPoolID *string `json:"elasticPoolId,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled', 'DatabaseStatusStopping', 'DatabaseStatusStopped', 'DatabaseStatusStarting' + Status DatabaseStatus `json:"status,omitempty"` + // DatabaseID - READ-ONLY; The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // CurrentServiceObjectiveName - READ-ONLY; The current service level objective name of the database. + CurrentServiceObjectiveName *string `json:"currentServiceObjectiveName,omitempty"` + // RequestedServiceObjectiveName - READ-ONLY; The requested service level objective name of the database. + RequestedServiceObjectiveName *string `json:"requestedServiceObjectiveName,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // FailoverGroupID - READ-ONLY; Failover Group resource identifier that this database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // SourceDatabaseDeletionDate - Specifies the time that the database was deleted. + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + // RecoveryServicesRecoveryPointID - The resource identifier of the recovery point associated with create operation of this database. + RecoveryServicesRecoveryPointID *string `json:"recoveryServicesRecoveryPointId,omitempty"` + // LongTermRetentionBackupResourceID - The resource identifier of the long term retention backup associated with create operation of this database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The resource identifier of the restorable dropped database associated with create operation of this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'CatalogCollationTypeDATABASEDEFAULT', 'CatalogCollationTypeSQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // ZoneRedundant - Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this database. `LicenseIncluded` if you need a license, or `BasePrice` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: 'DatabaseLicenseTypeLicenseIncluded', 'DatabaseLicenseTypeBasePrice' + LicenseType DatabaseLicenseType `json:"licenseType,omitempty"` + // MaxLogSizeBytes - READ-ONLY; The max log size for this database. + MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` + // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // ReadScale - The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' + ReadScale DatabaseReadScale `json:"readScale,omitempty"` + // HighAvailabilityReplicaCount - The number of secondary replicas associated with the database that are used to provide high availability. Not applicable to a Hyperscale database within an elastic pool. + HighAvailabilityReplicaCount *int32 `json:"highAvailabilityReplicaCount,omitempty"` + // SecondaryType - The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: 'SecondaryTypeGeo', 'SecondaryTypeNamed' + SecondaryType SecondaryType `json:"secondaryType,omitempty"` + // CurrentSku - READ-ONLY; The name and tier of the SKU. + CurrentSku *Sku `json:"currentSku,omitempty"` + // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled + AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` + // CurrentBackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + CurrentBackupStorageRedundancy BackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage account type to be used to store backups for this database. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` + // MinCapacity - Minimal capacity that database will always have allocated, if not paused + MinCapacity *float64 `json:"minCapacity,omitempty"` + // PausedDate - READ-ONLY; The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. + PausedDate *date.Time `json:"pausedDate,omitempty"` + // ResumedDate - READ-ONLY; The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. + ResumedDate *date.Time `json:"resumedDate,omitempty"` + // MaintenanceConfigurationID - Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // IsLedgerOn - Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. + IsLedgerOn *bool `json:"isLedgerOn,omitempty"` + // IsInfraEncryptionEnabled - READ-ONLY; Infra encryption is enabled for this database. + IsInfraEncryptionEnabled *bool `json:"isInfraEncryptionEnabled,omitempty"` + // FederatedClientID - The Client id used for cross tenant per database CMK scenario + FederatedClientID *uuid.UUID `json:"federatedClientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUpdateProperties. +func (dup DatabaseUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dup.CreateMode != "" { + objectMap["createMode"] = dup.CreateMode + } + if dup.Collation != nil { + objectMap["collation"] = dup.Collation + } + if dup.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = dup.MaxSizeBytes + } + if dup.SampleName != "" { + objectMap["sampleName"] = dup.SampleName + } + if dup.ElasticPoolID != nil { + objectMap["elasticPoolId"] = dup.ElasticPoolID + } + if dup.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = dup.SourceDatabaseID + } + if dup.RestorePointInTime != nil { + objectMap["restorePointInTime"] = dup.RestorePointInTime + } + if dup.SourceDatabaseDeletionDate != nil { + objectMap["sourceDatabaseDeletionDate"] = dup.SourceDatabaseDeletionDate + } + if dup.RecoveryServicesRecoveryPointID != nil { + objectMap["recoveryServicesRecoveryPointId"] = dup.RecoveryServicesRecoveryPointID + } + if dup.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = dup.LongTermRetentionBackupResourceID + } + if dup.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = dup.RecoverableDatabaseID + } + if dup.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = dup.RestorableDroppedDatabaseID + } + if dup.CatalogCollation != "" { + objectMap["catalogCollation"] = dup.CatalogCollation + } + if dup.ZoneRedundant != nil { + objectMap["zoneRedundant"] = dup.ZoneRedundant + } + if dup.LicenseType != "" { + objectMap["licenseType"] = dup.LicenseType + } + if dup.ReadScale != "" { + objectMap["readScale"] = dup.ReadScale + } + if dup.HighAvailabilityReplicaCount != nil { + objectMap["highAvailabilityReplicaCount"] = dup.HighAvailabilityReplicaCount + } + if dup.SecondaryType != "" { + objectMap["secondaryType"] = dup.SecondaryType + } + if dup.AutoPauseDelay != nil { + objectMap["autoPauseDelay"] = dup.AutoPauseDelay + } + if dup.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = dup.RequestedBackupStorageRedundancy + } + if dup.MinCapacity != nil { + objectMap["minCapacity"] = dup.MinCapacity + } + if dup.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = dup.MaintenanceConfigurationID + } + if dup.IsLedgerOn != nil { + objectMap["isLedgerOn"] = dup.IsLedgerOn + } + if dup.FederatedClientID != nil { + objectMap["federatedClientId"] = dup.FederatedClientID + } + return json.Marshal(objectMap) +} + +// DatabaseUsage usage metric of a database. +type DatabaseUsage struct { + // DatabaseUsageProperties - Resource properties. + *DatabaseUsageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUsage. +func (du DatabaseUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if du.DatabaseUsageProperties != nil { + objectMap["properties"] = du.DatabaseUsageProperties + } + return json.Marshal(objectMap) } // UnmarshalJSON is the custom unmarshaler for DatabaseUsage struct. @@ -4058,6 +4579,20 @@ func (dup DatabaseUsageProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// DatabaseUserIdentity azure Active Directory identity configuration for a resource. +type DatabaseUserIdentity struct { + // PrincipalID - READ-ONLY; The Azure Active Directory principal id. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The Azure Active Directory client id. + ClientID *uuid.UUID `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUserIdentity. +func (dui DatabaseUserIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + // DatabaseVulnerabilityAssessment a database vulnerability assessment. type DatabaseVulnerabilityAssessment struct { autorest.Response `json:"-"` @@ -5358,64 +5893,11 @@ func (future *DeletedServersRecoverFuture) result(client DeletedServersClient) ( return } -// DNSRefreshConfigurationProperties DNS refresh configuration properties. -type DNSRefreshConfigurationProperties struct { - // Status - READ-ONLY; The status of the DNS refresh operation. Possible values include: 'Status1Succeeded', 'Status1Failed' - Status Status1 `json:"status,omitempty"` -} - -// MarshalJSON is the custom marshaler for DNSRefreshConfigurationProperties. -func (drcp DNSRefreshConfigurationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// EditionCapability the edition capability. -type EditionCapability struct { - // Name - READ-ONLY; The database edition name. - Name *string `json:"name,omitempty"` - // SupportedServiceLevelObjectives - READ-ONLY; The list of supported service objectives for the edition. - SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` - // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // ReadScale - READ-ONLY; The read scale capability for the edition. - ReadScale *ReadScaleCapability `json:"readScale,omitempty"` - // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition - SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for EditionCapability. -func (ec EditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ec.Reason != nil { - objectMap["reason"] = ec.Reason - } - return json.Marshal(objectMap) -} - -// ElasticPool an elastic pool. -type ElasticPool struct { +// DistributedAvailabilityGroup distributed availability group between box and Sql Managed Instance. +type DistributedAvailabilityGroup struct { autorest.Response `json:"-"` - // Sku - The elastic pool SKU. - // - // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or the following command: - // - // ```azurecli - // az sql elastic-pool list-editions -l -o table - // ```` - Sku *Sku `json:"sku,omitempty"` - // Kind - READ-ONLY; Kind of elastic pool. This is metadata used for the Azure portal experience. - Kind *string `json:"kind,omitempty"` - // ElasticPoolProperties - Resource properties. - *ElasticPoolProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` + // DistributedAvailabilityGroupProperties - Resource properties. + *DistributedAvailabilityGroupProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -5424,26 +5906,17 @@ type ElasticPool struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPool. -func (ep ElasticPool) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for DistributedAvailabilityGroup. +func (dag DistributedAvailabilityGroup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ep.Sku != nil { - objectMap["sku"] = ep.Sku - } - if ep.ElasticPoolProperties != nil { - objectMap["properties"] = ep.ElasticPoolProperties - } - if ep.Location != nil { - objectMap["location"] = ep.Location - } - if ep.Tags != nil { - objectMap["tags"] = ep.Tags + if dag.DistributedAvailabilityGroupProperties != nil { + objectMap["properties"] = dag.DistributedAvailabilityGroupProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ElasticPool struct. -func (ep *ElasticPool) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for DistributedAvailabilityGroup struct. +func (dag *DistributedAvailabilityGroup) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -5451,50 +5924,14 @@ func (ep *ElasticPool) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - ep.Sku = &sku - } - case "kind": - if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - ep.Kind = &kind - } case "properties": if v != nil { - var elasticPoolProperties ElasticPoolProperties - err = json.Unmarshal(*v, &elasticPoolProperties) - if err != nil { - return err - } - ep.ElasticPoolProperties = &elasticPoolProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ep.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) + var distributedAvailabilityGroupProperties DistributedAvailabilityGroupProperties + err = json.Unmarshal(*v, &distributedAvailabilityGroupProperties) if err != nil { return err } - ep.Tags = tags + dag.DistributedAvailabilityGroupProperties = &distributedAvailabilityGroupProperties } case "id": if v != nil { @@ -5503,7 +5940,7 @@ func (ep *ElasticPool) UnmarshalJSON(body []byte) error { if err != nil { return err } - ep.ID = &ID + dag.ID = &ID } case "name": if v != nil { @@ -5512,7 +5949,7 @@ func (ep *ElasticPool) UnmarshalJSON(body []byte) error { if err != nil { return err } - ep.Name = &name + dag.Name = &name } case "type": if v != nil { @@ -5521,7 +5958,7 @@ func (ep *ElasticPool) UnmarshalJSON(body []byte) error { if err != nil { return err } - ep.Type = &typeVar + dag.Type = &typeVar } } } @@ -5529,347 +5966,173 @@ func (ep *ElasticPool) UnmarshalJSON(body []byte) error { return nil } -// ElasticPoolActivity represents the activity on an elastic pool. -type ElasticPoolActivity struct { - // Location - The geo-location where the resource lives - Location *string `json:"location,omitempty"` - // ElasticPoolActivityProperties - The properties representing the resource. - *ElasticPoolActivityProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// DistributedAvailabilityGroupProperties the properties of a distributed availability group. +type DistributedAvailabilityGroupProperties struct { + // TargetDatabase - The name of the target database + TargetDatabase *string `json:"targetDatabase,omitempty"` + // SourceEndpoint - The source endpoint + SourceEndpoint *string `json:"sourceEndpoint,omitempty"` + // PrimaryAvailabilityGroupName - The primary availability group name + PrimaryAvailabilityGroupName *string `json:"primaryAvailabilityGroupName,omitempty"` + // SecondaryAvailabilityGroupName - The secondary availability group name + SecondaryAvailabilityGroupName *string `json:"secondaryAvailabilityGroupName,omitempty"` + // ReplicationMode - The replication mode of a distributed availability group. Parameter will be ignored during link creation. Possible values include: 'ReplicationModeAsync', 'ReplicationModeSync' + ReplicationMode ReplicationMode `json:"replicationMode,omitempty"` + // DistributedAvailabilityGroupID - READ-ONLY; The distributed availability group id + DistributedAvailabilityGroupID *uuid.UUID `json:"distributedAvailabilityGroupId,omitempty"` + // SourceReplicaID - READ-ONLY; The source replica id + SourceReplicaID *uuid.UUID `json:"sourceReplicaId,omitempty"` + // TargetReplicaID - READ-ONLY; The target replica id + TargetReplicaID *uuid.UUID `json:"targetReplicaId,omitempty"` + // LinkState - READ-ONLY; The link state + LinkState *string `json:"linkState,omitempty"` + // LastHardenedLsn - READ-ONLY; The last hardened lsn + LastHardenedLsn *string `json:"lastHardenedLsn,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPoolActivity. -func (epa ElasticPoolActivity) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for DistributedAvailabilityGroupProperties. +func (dagp DistributedAvailabilityGroupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if epa.Location != nil { - objectMap["location"] = epa.Location + if dagp.TargetDatabase != nil { + objectMap["targetDatabase"] = dagp.TargetDatabase } - if epa.ElasticPoolActivityProperties != nil { - objectMap["properties"] = epa.ElasticPoolActivityProperties + if dagp.SourceEndpoint != nil { + objectMap["sourceEndpoint"] = dagp.SourceEndpoint + } + if dagp.PrimaryAvailabilityGroupName != nil { + objectMap["primaryAvailabilityGroupName"] = dagp.PrimaryAvailabilityGroupName + } + if dagp.SecondaryAvailabilityGroupName != nil { + objectMap["secondaryAvailabilityGroupName"] = dagp.SecondaryAvailabilityGroupName + } + if dagp.ReplicationMode != "" { + objectMap["replicationMode"] = dagp.ReplicationMode } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ElasticPoolActivity struct. -func (epa *ElasticPoolActivity) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { +// DistributedAvailabilityGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type DistributedAvailabilityGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DistributedAvailabilityGroupsClient) (DistributedAvailabilityGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DistributedAvailabilityGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { return err } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - epa.Location = &location - } - case "properties": - if v != nil { - var elasticPoolActivityProperties ElasticPoolActivityProperties - err = json.Unmarshal(*v, &elasticPoolActivityProperties) - if err != nil { - return err - } - epa.ElasticPoolActivityProperties = &elasticPoolActivityProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - epa.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - epa.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - epa.Type = &typeVar - } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DistributedAvailabilityGroupsCreateOrUpdateFuture.Result. +func (future *DistributedAvailabilityGroupsCreateOrUpdateFuture) result(client DistributedAvailabilityGroupsClient) (dag DistributedAvailabilityGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + dag.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DistributedAvailabilityGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dag.Response.Response, err = future.GetResult(sender); err == nil && dag.Response.Response.StatusCode != http.StatusNoContent { + dag, err = client.CreateOrUpdateResponder(dag.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsCreateOrUpdateFuture", "Result", dag.Response.Response, "Failure responding to request") } } + return +} + +// DistributedAvailabilityGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DistributedAvailabilityGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DistributedAvailabilityGroupsClient) (autorest.Response, error) +} +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DistributedAvailabilityGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result return nil } -// ElasticPoolActivityListResult represents the response to a list elastic pool activity request. -type ElasticPoolActivityListResult struct { - autorest.Response `json:"-"` - // Value - The list of elastic pool activities. - Value *[]ElasticPoolActivity `json:"value,omitempty"` +// result is the default implementation for DistributedAvailabilityGroupsDeleteFuture.Result. +func (future *DistributedAvailabilityGroupsDeleteFuture) result(client DistributedAvailabilityGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DistributedAvailabilityGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return } -// ElasticPoolActivityProperties represents the properties of an elastic pool. -type ElasticPoolActivityProperties struct { - // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). - EndTime *date.Time `json:"endTime,omitempty"` - // ErrorCode - READ-ONLY; The error code if available. - ErrorCode *int32 `json:"errorCode,omitempty"` - // ErrorMessage - READ-ONLY; The error message if available. - ErrorMessage *string `json:"errorMessage,omitempty"` - // ErrorSeverity - READ-ONLY; The error severity if available. - ErrorSeverity *int32 `json:"errorSeverity,omitempty"` - // Operation - READ-ONLY; The operation name. - Operation *string `json:"operation,omitempty"` - // OperationID - READ-ONLY; The unique operation ID. - OperationID *uuid.UUID `json:"operationId,omitempty"` - // PercentComplete - READ-ONLY; The percentage complete if available. - PercentComplete *int32 `json:"percentComplete,omitempty"` - // RequestedDatabaseDtuMax - READ-ONLY; The requested max DTU per database if available. - RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` - // RequestedDatabaseDtuMin - READ-ONLY; The requested min DTU per database if available. - RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` - // RequestedDtu - READ-ONLY; The requested DTU for the pool if available. - RequestedDtu *int32 `json:"requestedDtu,omitempty"` - // RequestedElasticPoolName - READ-ONLY; The requested name for the elastic pool if available. - RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` - // RequestedStorageLimitInGB - READ-ONLY; The requested storage limit for the pool in GB if available. - RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` - // ElasticPoolName - READ-ONLY; The name of the elastic pool. - ElasticPoolName *string `json:"elasticPoolName,omitempty"` - // ServerName - READ-ONLY; The name of the server the elastic pool is in. - ServerName *string `json:"serverName,omitempty"` - // StartTime - READ-ONLY; The time the operation started (ISO8601 format). - StartTime *date.Time `json:"startTime,omitempty"` - // State - READ-ONLY; The current state of the operation. - State *string `json:"state,omitempty"` - // RequestedStorageLimitInMB - READ-ONLY; The requested storage limit in MB. - RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` - // RequestedDatabaseDtuGuarantee - READ-ONLY; The requested per database DTU guarantee. - RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` - // RequestedDatabaseDtuCap - READ-ONLY; The requested per database DTU cap. - RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` - // RequestedDtuGuarantee - READ-ONLY; The requested DTU guarantee. - RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,omitempty"` +// DistributedAvailabilityGroupsListResult a list of distributed availability groups in instance. +type DistributedAvailabilityGroupsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DistributedAvailabilityGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPoolActivityProperties. -func (epap ElasticPoolActivityProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for DistributedAvailabilityGroupsListResult. +func (daglr DistributedAvailabilityGroupsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ElasticPoolDatabaseActivity represents the activity on an elastic pool. -type ElasticPoolDatabaseActivity struct { - // Location - The geo-location where the resource lives - Location *string `json:"location,omitempty"` - // ElasticPoolDatabaseActivityProperties - The properties representing the resource. - *ElasticPoolDatabaseActivityProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// DistributedAvailabilityGroupsListResultIterator provides access to a complete listing of +// DistributedAvailabilityGroup values. +type DistributedAvailabilityGroupsListResultIterator struct { + i int + page DistributedAvailabilityGroupsListResultPage } -// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivity. -func (epda ElasticPoolDatabaseActivity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if epda.Location != nil { - objectMap["location"] = epda.Location +// NextWithContext 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 *DistributedAvailabilityGroupsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() } - if epda.ElasticPoolDatabaseActivityProperties != nil { - objectMap["properties"] = epda.ElasticPoolDatabaseActivityProperties + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ElasticPoolDatabaseActivity struct. -func (epda *ElasticPoolDatabaseActivity) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) + err = iter.page.NextWithContext(ctx) if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - epda.Location = &location - } - case "properties": - if v != nil { - var elasticPoolDatabaseActivityProperties ElasticPoolDatabaseActivityProperties - err = json.Unmarshal(*v, &elasticPoolDatabaseActivityProperties) - if err != nil { - return err - } - epda.ElasticPoolDatabaseActivityProperties = &elasticPoolDatabaseActivityProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - epda.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - epda.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - epda.Type = &typeVar - } - } - } - - return nil -} - -// ElasticPoolDatabaseActivityListResult represents the response to a list elastic pool database activity -// request. -type ElasticPoolDatabaseActivityListResult struct { - autorest.Response `json:"-"` - // Value - The list of elastic pool database activities. - Value *[]ElasticPoolDatabaseActivity `json:"value,omitempty"` -} - -// ElasticPoolDatabaseActivityProperties represents the properties of an elastic pool database activity. -type ElasticPoolDatabaseActivityProperties struct { - // DatabaseName - READ-ONLY; The database name. - DatabaseName *string `json:"databaseName,omitempty"` - // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). - EndTime *date.Time `json:"endTime,omitempty"` - // ErrorCode - READ-ONLY; The error code if available. - ErrorCode *int32 `json:"errorCode,omitempty"` - // ErrorMessage - READ-ONLY; The error message if available. - ErrorMessage *string `json:"errorMessage,omitempty"` - // ErrorSeverity - READ-ONLY; The error severity if available. - ErrorSeverity *int32 `json:"errorSeverity,omitempty"` - // Operation - READ-ONLY; The operation name. - Operation *string `json:"operation,omitempty"` - // OperationID - READ-ONLY; The unique operation ID. - OperationID *uuid.UUID `json:"operationId,omitempty"` - // PercentComplete - READ-ONLY; The percentage complete if available. - PercentComplete *int32 `json:"percentComplete,omitempty"` - // RequestedElasticPoolName - READ-ONLY; The name for the elastic pool the database is moving into if available. - RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` - // CurrentElasticPoolName - READ-ONLY; The name of the current elastic pool the database is in if available. - CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` - // CurrentServiceObjective - READ-ONLY; The name of the current service objective if available. - CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` - // RequestedServiceObjective - READ-ONLY; The name of the requested service objective if available. - RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` - // ServerName - READ-ONLY; The name of the server the elastic pool is in. - ServerName *string `json:"serverName,omitempty"` - // StartTime - READ-ONLY; The time the operation started (ISO8601 format). - StartTime *date.Time `json:"startTime,omitempty"` - // State - READ-ONLY; The current state of the operation. - State *string `json:"state,omitempty"` -} - -// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivityProperties. -func (epdap ElasticPoolDatabaseActivityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ElasticPoolEditionCapability the elastic pool edition capability. -type ElasticPoolEditionCapability struct { - // Name - READ-ONLY; The elastic pool edition name. - Name *string `json:"name,omitempty"` - // SupportedElasticPoolPerformanceLevels - READ-ONLY; The list of supported elastic pool DTU levels for the edition. - SupportedElasticPoolPerformanceLevels *[]ElasticPoolPerformanceLevelCapability `json:"supportedElasticPoolPerformanceLevels,omitempty"` - // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for ElasticPoolEditionCapability. -func (epec ElasticPoolEditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if epec.Reason != nil { - objectMap["reason"] = epec.Reason - } - return json.Marshal(objectMap) -} - -// ElasticPoolListResult the result of an elastic pool list request. -type ElasticPoolListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]ElasticPool `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ElasticPoolListResult. -func (eplr ElasticPoolListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ElasticPoolListResultIterator provides access to a complete listing of ElasticPool values. -type ElasticPoolListResultIterator struct { - i int - page ElasticPoolListResultPage -} - -// NextWithContext 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 *ElasticPoolListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- + iter.i-- return err } iter.i = 0 @@ -5879,67 +6142,67 @@ func (iter *ElasticPoolListResultIterator) NextWithContext(ctx context.Context) // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ElasticPoolListResultIterator) Next() error { +func (iter *DistributedAvailabilityGroupsListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ElasticPoolListResultIterator) NotDone() bool { +func (iter DistributedAvailabilityGroupsListResultIterator) 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 ElasticPoolListResultIterator) Response() ElasticPoolListResult { +func (iter DistributedAvailabilityGroupsListResultIterator) Response() DistributedAvailabilityGroupsListResult { 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 ElasticPoolListResultIterator) Value() ElasticPool { +func (iter DistributedAvailabilityGroupsListResultIterator) Value() DistributedAvailabilityGroup { if !iter.page.NotDone() { - return ElasticPool{} + return DistributedAvailabilityGroup{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ElasticPoolListResultIterator type. -func NewElasticPoolListResultIterator(page ElasticPoolListResultPage) ElasticPoolListResultIterator { - return ElasticPoolListResultIterator{page: page} +// Creates a new instance of the DistributedAvailabilityGroupsListResultIterator type. +func NewDistributedAvailabilityGroupsListResultIterator(page DistributedAvailabilityGroupsListResultPage) DistributedAvailabilityGroupsListResultIterator { + return DistributedAvailabilityGroupsListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (eplr ElasticPoolListResult) IsEmpty() bool { - return eplr.Value == nil || len(*eplr.Value) == 0 +func (daglr DistributedAvailabilityGroupsListResult) IsEmpty() bool { + return daglr.Value == nil || len(*daglr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (eplr ElasticPoolListResult) hasNextLink() bool { - return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +func (daglr DistributedAvailabilityGroupsListResult) hasNextLink() bool { + return daglr.NextLink != nil && len(*daglr.NextLink) != 0 } -// elasticPoolListResultPreparer prepares a request to retrieve the next set of results. +// distributedAvailabilityGroupsListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (eplr ElasticPoolListResult) elasticPoolListResultPreparer(ctx context.Context) (*http.Request, error) { - if !eplr.hasNextLink() { +func (daglr DistributedAvailabilityGroupsListResult) distributedAvailabilityGroupsListResultPreparer(ctx context.Context) (*http.Request, error) { + if !daglr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(eplr.NextLink))) + autorest.WithBaseURL(to.String(daglr.NextLink))) } -// ElasticPoolListResultPage contains a page of ElasticPool values. -type ElasticPoolListResultPage struct { - fn func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error) - eplr ElasticPoolListResult +// DistributedAvailabilityGroupsListResultPage contains a page of DistributedAvailabilityGroup values. +type DistributedAvailabilityGroupsListResultPage struct { + fn func(context.Context, DistributedAvailabilityGroupsListResult) (DistributedAvailabilityGroupsListResult, error) + daglr DistributedAvailabilityGroupsListResult } // NextWithContext 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 *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *DistributedAvailabilityGroupsListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/DistributedAvailabilityGroupsListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -5949,11 +6212,11 @@ func (page *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err }() } for { - next, err := page.fn(ctx, page.eplr) + next, err := page.fn(ctx, page.daglr) if err != nil { return err } - page.eplr = next + page.daglr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -5964,627 +6227,738 @@ func (page *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err // 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. // Deprecated: Use NextWithContext() instead. -func (page *ElasticPoolListResultPage) Next() error { +func (page *DistributedAvailabilityGroupsListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ElasticPoolListResultPage) NotDone() bool { - return !page.eplr.IsEmpty() +func (page DistributedAvailabilityGroupsListResultPage) NotDone() bool { + return !page.daglr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ElasticPoolListResultPage) Response() ElasticPoolListResult { - return page.eplr +func (page DistributedAvailabilityGroupsListResultPage) Response() DistributedAvailabilityGroupsListResult { + return page.daglr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ElasticPoolListResultPage) Values() []ElasticPool { - if page.eplr.IsEmpty() { +func (page DistributedAvailabilityGroupsListResultPage) Values() []DistributedAvailabilityGroup { + if page.daglr.IsEmpty() { return nil } - return *page.eplr.Value + return *page.daglr.Value } -// Creates a new instance of the ElasticPoolListResultPage type. -func NewElasticPoolListResultPage(cur ElasticPoolListResult, getNextPage func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error)) ElasticPoolListResultPage { - return ElasticPoolListResultPage{ - fn: getNextPage, - eplr: cur, +// Creates a new instance of the DistributedAvailabilityGroupsListResultPage type. +func NewDistributedAvailabilityGroupsListResultPage(cur DistributedAvailabilityGroupsListResult, getNextPage func(context.Context, DistributedAvailabilityGroupsListResult) (DistributedAvailabilityGroupsListResult, error)) DistributedAvailabilityGroupsListResultPage { + return DistributedAvailabilityGroupsListResultPage{ + fn: getNextPage, + daglr: cur, } } -// ElasticPoolOperation a elastic pool operation. -type ElasticPoolOperation struct { - // ElasticPoolOperationProperties - Resource properties. - *ElasticPoolOperationProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// DistributedAvailabilityGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DistributedAvailabilityGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DistributedAvailabilityGroupsClient) (DistributedAvailabilityGroup, error) } -// MarshalJSON is the custom marshaler for ElasticPoolOperation. -func (epo ElasticPoolOperation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if epo.ElasticPoolOperationProperties != nil { - objectMap["properties"] = epo.ElasticPoolOperationProperties +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DistributedAvailabilityGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return json.Marshal(objectMap) + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// UnmarshalJSON is the custom unmarshaler for ElasticPoolOperation struct. -func (epo *ElasticPoolOperation) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// result is the default implementation for DistributedAvailabilityGroupsUpdateFuture.Result. +func (future *DistributedAvailabilityGroupsUpdateFuture) result(client DistributedAvailabilityGroupsClient) (dag DistributedAvailabilityGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) if err != nil { - return err + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var elasticPoolOperationProperties ElasticPoolOperationProperties - err = json.Unmarshal(*v, &elasticPoolOperationProperties) - if err != nil { - return err - } - epo.ElasticPoolOperationProperties = &elasticPoolOperationProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - epo.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - epo.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - epo.Type = &typeVar - } + if !done { + dag.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DistributedAvailabilityGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dag.Response.Response, err = future.GetResult(sender); err == nil && dag.Response.Response.StatusCode != http.StatusNoContent { + dag, err = client.UpdateResponder(dag.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DistributedAvailabilityGroupsUpdateFuture", "Result", dag.Response.Response, "Failure responding to request") } } + return +} - return nil +// DNSRefreshConfigurationProperties DNS refresh configuration properties. +type DNSRefreshConfigurationProperties struct { + // Status - READ-ONLY; The status of the DNS refresh operation. Possible values include: 'Status1Succeeded', 'Status1Failed' + Status Status1 `json:"status,omitempty"` } -// ElasticPoolOperationListResult the response to a list elastic pool operations request -type ElasticPoolOperationListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]ElasticPoolOperation `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ElasticPoolOperationListResult. -func (epolr ElasticPoolOperationListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for DNSRefreshConfigurationProperties. +func (drcp DNSRefreshConfigurationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ElasticPoolOperationListResultIterator provides access to a complete listing of ElasticPoolOperation -// values. -type ElasticPoolOperationListResultIterator struct { - i int - page ElasticPoolOperationListResultPage +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - READ-ONLY; The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - READ-ONLY; The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // ReadScale - READ-ONLY; The read scale capability for the edition. + ReadScale *ReadScaleCapability `json:"readScale,omitempty"` + // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition + SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` } -// NextWithContext 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 *ElasticPoolOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err +// MarshalJSON is the custom marshaler for EditionCapability. +func (ec EditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.Reason != nil { + objectMap["reason"] = ec.Reason } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ElasticPoolOperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ElasticPoolOperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) + return json.Marshal(objectMap) } -// Response returns the raw server response from the last page request. -func (iter ElasticPoolOperationListResultIterator) Response() ElasticPoolOperationListResult { - return iter.page.Response() +// ElasticPool an elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // Sku - The elastic pool SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or the following command: + // + // ```azurecli + // az sql elastic-pool list-editions -l -o table + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ElasticPoolProperties - Resource properties. + *ElasticPoolProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ElasticPoolOperationListResultIterator) Value() ElasticPoolOperation { - if !iter.page.NotDone() { - return ElasticPoolOperation{} +// MarshalJSON is the custom marshaler for ElasticPool. +func (ep ElasticPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.Sku != nil { + objectMap["sku"] = ep.Sku } - return iter.page.Values()[iter.i] + if ep.ElasticPoolProperties != nil { + objectMap["properties"] = ep.ElasticPoolProperties + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + return json.Marshal(objectMap) } -// Creates a new instance of the ElasticPoolOperationListResultIterator type. -func NewElasticPoolOperationListResultIterator(page ElasticPoolOperationListResultPage) ElasticPoolOperationListResultIterator { - return ElasticPoolOperationListResultIterator{page: page} -} +// UnmarshalJSON is the custom unmarshaler for ElasticPool struct. +func (ep *ElasticPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ep.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "properties": + if v != nil { + var elasticPoolProperties ElasticPoolProperties + err = json.Unmarshal(*v, &elasticPoolProperties) + if err != nil { + return err + } + ep.ElasticPoolProperties = &elasticPoolProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } -// IsEmpty returns true if the ListResult contains no values. -func (epolr ElasticPoolOperationListResult) IsEmpty() bool { - return epolr.Value == nil || len(*epolr.Value) == 0 + return nil } -// hasNextLink returns true if the NextLink is not empty. -func (epolr ElasticPoolOperationListResult) hasNextLink() bool { - return epolr.NextLink != nil && len(*epolr.NextLink) != 0 +// ElasticPoolActivity represents the activity on an elastic pool. +type ElasticPoolActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolActivityProperties - The properties representing the resource. + *ElasticPoolActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// elasticPoolOperationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (epolr ElasticPoolOperationListResult) elasticPoolOperationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !epolr.hasNextLink() { - return nil, nil +// MarshalJSON is the custom marshaler for ElasticPoolActivity. +func (epa ElasticPoolActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epa.Location != nil { + objectMap["location"] = epa.Location } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(epolr.NextLink))) -} - -// ElasticPoolOperationListResultPage contains a page of ElasticPoolOperation values. -type ElasticPoolOperationListResultPage struct { - fn func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error) - epolr ElasticPoolOperationListResult + if epa.ElasticPoolActivityProperties != nil { + objectMap["properties"] = epa.ElasticPoolActivityProperties + } + return json.Marshal(objectMap) } -// NextWithContext 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 *ElasticPoolOperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() +// UnmarshalJSON is the custom unmarshaler for ElasticPoolActivity struct. +func (epa *ElasticPoolActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err } - for { - next, err := page.fn(ctx, page.epolr) - if err != nil { - return err - } - page.epolr = next - if !next.hasNextLink() || !next.IsEmpty() { - break + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epa.Location = &location + } + case "properties": + if v != nil { + var elasticPoolActivityProperties ElasticPoolActivityProperties + err = json.Unmarshal(*v, &elasticPoolActivityProperties) + if err != nil { + return err + } + epa.ElasticPoolActivityProperties = &elasticPoolActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epa.Type = &typeVar + } } } - return nil -} - -// 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. -// Deprecated: Use NextWithContext() instead. -func (page *ElasticPoolOperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ElasticPoolOperationListResultPage) NotDone() bool { - return !page.epolr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ElasticPoolOperationListResultPage) Response() ElasticPoolOperationListResult { - return page.epolr -} -// Values returns the slice of values for the current page or nil if there are no values. -func (page ElasticPoolOperationListResultPage) Values() []ElasticPoolOperation { - if page.epolr.IsEmpty() { - return nil - } - return *page.epolr.Value + return nil } -// Creates a new instance of the ElasticPoolOperationListResultPage type. -func NewElasticPoolOperationListResultPage(cur ElasticPoolOperationListResult, getNextPage func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error)) ElasticPoolOperationListResultPage { - return ElasticPoolOperationListResultPage{ - fn: getNextPage, - epolr: cur, - } +// ElasticPoolActivityListResult represents the response to a list elastic pool activity request. +type ElasticPoolActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool activities. + Value *[]ElasticPoolActivity `json:"value,omitempty"` } -// ElasticPoolOperationProperties the properties of a elastic pool operation. -type ElasticPoolOperationProperties struct { - // ElasticPoolName - READ-ONLY; The name of the elastic pool the operation is being performed on. - ElasticPoolName *string `json:"elasticPoolName,omitempty"` - // Operation - READ-ONLY; The name of operation. +// ElasticPoolActivityProperties represents the properties of an elastic pool. +type ElasticPoolActivityProperties struct { + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. Operation *string `json:"operation,omitempty"` - // OperationFriendlyName - READ-ONLY; The friendly name of operation. - OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` - // PercentComplete - READ-ONLY; The percentage of the operation completed. + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. PercentComplete *int32 `json:"percentComplete,omitempty"` - // ServerName - READ-ONLY; The name of the server. + // RequestedDatabaseDtuMax - READ-ONLY; The requested max DTU per database if available. + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + // RequestedDatabaseDtuMin - READ-ONLY; The requested min DTU per database if available. + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + // RequestedDtu - READ-ONLY; The requested DTU for the pool if available. + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The requested name for the elastic pool if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // RequestedStorageLimitInGB - READ-ONLY; The requested storage limit for the pool in GB if available. + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + // ElasticPoolName - READ-ONLY; The name of the elastic pool. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. ServerName *string `json:"serverName,omitempty"` - // StartTime - READ-ONLY; The operation start time. + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). StartTime *date.Time `json:"startTime,omitempty"` - // State - READ-ONLY; The operation state. + // State - READ-ONLY; The current state of the operation. State *string `json:"state,omitempty"` - // ErrorCode - READ-ONLY; The operation error code. - ErrorCode *int32 `json:"errorCode,omitempty"` - // ErrorDescription - READ-ONLY; The operation error description. - ErrorDescription *string `json:"errorDescription,omitempty"` - // ErrorSeverity - READ-ONLY; The operation error severity. - ErrorSeverity *int32 `json:"errorSeverity,omitempty"` - // IsUserError - READ-ONLY; Whether or not the error is a user error. - IsUserError *bool `json:"isUserError,omitempty"` - // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. - EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` - // Description - READ-ONLY; The operation description. - Description *string `json:"description,omitempty"` - // IsCancellable - READ-ONLY; Whether the operation can be cancelled. - IsCancellable *bool `json:"isCancellable,omitempty"` + // RequestedStorageLimitInMB - READ-ONLY; The requested storage limit in MB. + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + // RequestedDatabaseDtuGuarantee - READ-ONLY; The requested per database DTU guarantee. + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + // RequestedDatabaseDtuCap - READ-ONLY; The requested per database DTU cap. + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + // RequestedDtuGuarantee - READ-ONLY; The requested DTU guarantee. + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPoolOperationProperties. -func (epop ElasticPoolOperationProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ElasticPoolActivityProperties. +func (epap ElasticPoolActivityProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ElasticPoolPerDatabaseMaxPerformanceLevelCapability the max per-database performance level capability. -type ElasticPoolPerDatabaseMaxPerformanceLevelCapability struct { - // Limit - READ-ONLY; The maximum performance level per database. - Limit *float64 `json:"limit,omitempty"` - // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' - Unit PerformanceLevelUnit `json:"unit,omitempty"` - // SupportedPerDatabaseMinPerformanceLevels - READ-ONLY; The list of supported min database performance levels. - SupportedPerDatabaseMinPerformanceLevels *[]ElasticPoolPerDatabaseMinPerformanceLevelCapability `json:"supportedPerDatabaseMinPerformanceLevels,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` +// ElasticPoolDatabaseActivity represents the activity on an elastic pool. +type ElasticPoolDatabaseActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolDatabaseActivityProperties - The properties representing the resource. + *ElasticPoolDatabaseActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMaxPerformanceLevelCapability. -func (eppdmplc ElasticPoolPerDatabaseMaxPerformanceLevelCapability) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivity. +func (epda ElasticPoolDatabaseActivity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if eppdmplc.Reason != nil { - objectMap["reason"] = eppdmplc.Reason + if epda.Location != nil { + objectMap["location"] = epda.Location } - return json.Marshal(objectMap) -} - -// ElasticPoolPerDatabaseMinPerformanceLevelCapability the minimum per-database performance level -// capability. -type ElasticPoolPerDatabaseMinPerformanceLevelCapability struct { - // Limit - READ-ONLY; The minimum performance level per database. - Limit *float64 `json:"limit,omitempty"` - // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' - Unit PerformanceLevelUnit `json:"unit,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMinPerformanceLevelCapability. -func (eppdmplc ElasticPoolPerDatabaseMinPerformanceLevelCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if eppdmplc.Reason != nil { - objectMap["reason"] = eppdmplc.Reason + if epda.ElasticPoolDatabaseActivityProperties != nil { + objectMap["properties"] = epda.ElasticPoolDatabaseActivityProperties } return json.Marshal(objectMap) } -// ElasticPoolPerDatabaseSettings per database settings of an elastic pool. -type ElasticPoolPerDatabaseSettings struct { - // MinCapacity - The minimum capacity all databases are guaranteed. - MinCapacity *float64 `json:"minCapacity,omitempty"` - // MaxCapacity - The maximum capacity any one database can consume. - MaxCapacity *float64 `json:"maxCapacity,omitempty"` -} - -// ElasticPoolPerformanceLevelCapability the Elastic Pool performance level capability. -type ElasticPoolPerformanceLevelCapability struct { - // PerformanceLevel - READ-ONLY; The performance level for the pool. - PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` - // Sku - READ-ONLY; The sku. - Sku *Sku `json:"sku,omitempty"` - // SupportedLicenseTypes - READ-ONLY; List of supported license types. - SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` - // MaxDatabaseCount - READ-ONLY; The maximum number of databases supported. - MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` - // IncludedMaxSize - READ-ONLY; The included (free) max size for this performance level. - IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` - // SupportedMaxSizes - READ-ONLY; The list of supported max sizes. - SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` - // SupportedPerDatabaseMaxSizes - READ-ONLY; The list of supported per database max sizes. - SupportedPerDatabaseMaxSizes *[]MaxSizeRangeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` - // SupportedPerDatabaseMaxPerformanceLevels - READ-ONLY; The list of supported per database max performance levels. - SupportedPerDatabaseMaxPerformanceLevels *[]ElasticPoolPerDatabaseMaxPerformanceLevelCapability `json:"supportedPerDatabaseMaxPerformanceLevels,omitempty"` - // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the performance level. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations - SupportedMaintenanceConfigurations *[]MaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` +// UnmarshalJSON is the custom unmarshaler for ElasticPoolDatabaseActivity struct. +func (epda *ElasticPoolDatabaseActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epda.Location = &location + } + case "properties": + if v != nil { + var elasticPoolDatabaseActivityProperties ElasticPoolDatabaseActivityProperties + err = json.Unmarshal(*v, &elasticPoolDatabaseActivityProperties) + if err != nil { + return err + } + epda.ElasticPoolDatabaseActivityProperties = &elasticPoolDatabaseActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epda.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epda.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epda.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolDatabaseActivityListResult represents the response to a list elastic pool database activity +// request. +type ElasticPoolDatabaseActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool database activities. + Value *[]ElasticPoolDatabaseActivity `json:"value,omitempty"` +} + +// ElasticPoolDatabaseActivityProperties represents the properties of an elastic pool database activity. +type ElasticPoolDatabaseActivityProperties struct { + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The name for the elastic pool the database is moving into if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // CurrentElasticPoolName - READ-ONLY; The name of the current elastic pool the database is in if available. + CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` + // CurrentServiceObjective - READ-ONLY; The name of the current service objective if available. + CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` + // RequestedServiceObjective - READ-ONLY; The name of the requested service objective if available. + RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivityProperties. +func (epdap ElasticPoolDatabaseActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolEditionCapability the elastic pool edition capability. +type ElasticPoolEditionCapability struct { + // Name - READ-ONLY; The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolPerformanceLevels - READ-ONLY; The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolPerformanceLevels *[]ElasticPoolPerformanceLevelCapability `json:"supportedElasticPoolPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' Status CapabilityStatus `json:"status,omitempty"` // Reason - The reason for the capability not being available. Reason *string `json:"reason,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPoolPerformanceLevelCapability. -func (epplc ElasticPoolPerformanceLevelCapability) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ElasticPoolEditionCapability. +func (epec ElasticPoolEditionCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if epplc.Reason != nil { - objectMap["reason"] = epplc.Reason + if epec.Reason != nil { + objectMap["reason"] = epec.Reason } return json.Marshal(objectMap) } -// ElasticPoolProperties properties of an elastic pool -type ElasticPoolProperties struct { - // State - READ-ONLY; The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' - State ElasticPoolState `json:"state,omitempty"` - // CreationDate - READ-ONLY; The creation date of the elastic pool (ISO8601 format). - CreationDate *date.Time `json:"creationDate,omitempty"` - // MaxSizeBytes - The storage limit for the database elastic pool in bytes. - MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` - // PerDatabaseSettings - The per database settings for the elastic pool. - PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` - // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' - LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` - // MaintenanceConfigurationID - Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. - MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` +// ElasticPoolListResult the result of an elastic pool list request. +type ElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ElasticPoolProperties. -func (epp ElasticPoolProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ElasticPoolListResult. +func (eplr ElasticPoolListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if epp.MaxSizeBytes != nil { - objectMap["maxSizeBytes"] = epp.MaxSizeBytes - } - if epp.PerDatabaseSettings != nil { - objectMap["perDatabaseSettings"] = epp.PerDatabaseSettings - } - if epp.ZoneRedundant != nil { - objectMap["zoneRedundant"] = epp.ZoneRedundant - } - if epp.LicenseType != "" { - objectMap["licenseType"] = epp.LicenseType - } - if epp.MaintenanceConfigurationID != nil { - objectMap["maintenanceConfigurationId"] = epp.MaintenanceConfigurationID - } return json.Marshal(objectMap) } -// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ElasticPoolsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ElasticPoolsClient) (ElasticPool, error) +// ElasticPoolListResultIterator provides access to a complete listing of ElasticPool values. +type ElasticPoolListResultIterator struct { + i int + page ElasticPoolListResultPage } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ElasticPoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { +// NextWithContext 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 *ElasticPoolListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- return err } - future.FutureAPI = &azFuture - future.Result = future.result + iter.i = 0 return nil } -// result is the default implementation for ElasticPoolsCreateOrUpdateFuture.Result. -func (future *ElasticPoolsCreateOrUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ep.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { - ep, err = client.CreateOrUpdateResponder(ep.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") - } - } - return +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) } -// ElasticPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ElasticPoolsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ElasticPoolsClient) (autorest.Response, error) +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ElasticPoolsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// Response returns the raw server response from the last page request. +func (iter ElasticPoolListResultIterator) Response() ElasticPoolListResult { + return iter.page.Response() } -// result is the default implementation for ElasticPoolsDeleteFuture.Result. -func (future *ElasticPoolsDeleteFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsDeleteFuture") - return +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ElasticPoolListResultIterator) Value() ElasticPool { + if !iter.page.NotDone() { + return ElasticPool{} } - ar.Response = future.Response() - return + return iter.page.Values()[iter.i] } -// ElasticPoolsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ElasticPoolsFailoverFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ElasticPoolsClient) (autorest.Response, error) +// Creates a new instance of the ElasticPoolListResultIterator type. +func NewElasticPoolListResultIterator(page ElasticPoolListResultPage) ElasticPoolListResultIterator { + return ElasticPoolListResultIterator{page: page} } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ElasticPoolsFailoverFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// IsEmpty returns true if the ListResult contains no values. +func (eplr ElasticPoolListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 } -// result is the default implementation for ElasticPoolsFailoverFuture.Result. -func (future *ElasticPoolsFailoverFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsFailoverFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsFailoverFuture") - return - } - ar.Response = future.Response() - return +// hasNextLink returns true if the NextLink is not empty. +func (eplr ElasticPoolListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 } -// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ElasticPoolsUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ElasticPoolsClient) (ElasticPool, error) +// elasticPoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr ElasticPoolListResult) elasticPoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ElasticPoolsUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// ElasticPoolListResultPage contains a page of ElasticPool values. +type ElasticPoolListResultPage struct { + fn func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error) + eplr ElasticPoolListResult } -// result is the default implementation for ElasticPoolsUpdateFuture.Result. -func (future *ElasticPoolsUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ep.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") - return +// NextWithContext 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 *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { - ep, err = client.UpdateResponder(ep.Response.Response) + for { + next, err := page.fn(ctx, page.eplr) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break } } - return + return nil } -// ElasticPoolUpdate an elastic pool update. -type ElasticPoolUpdate struct { - Sku *Sku `json:"sku,omitempty"` - // ElasticPoolUpdateProperties - Resource properties. - *ElasticPoolUpdateProperties `json:"properties,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolListResultPage) Next() error { + return page.NextWithContext(context.Background()) } -// MarshalJSON is the custom marshaler for ElasticPoolUpdate. -func (epu ElasticPoolUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if epu.Sku != nil { - objectMap["sku"] = epu.Sku +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolListResultPage) Response() ElasticPoolListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolListResultPage) Values() []ElasticPool { + if page.eplr.IsEmpty() { + return nil } - if epu.ElasticPoolUpdateProperties != nil { - objectMap["properties"] = epu.ElasticPoolUpdateProperties + return *page.eplr.Value +} + +// Creates a new instance of the ElasticPoolListResultPage type. +func NewElasticPoolListResultPage(cur ElasticPoolListResult, getNextPage func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error)) ElasticPoolListResultPage { + return ElasticPoolListResultPage{ + fn: getNextPage, + eplr: cur, } - if epu.Tags != nil { - objectMap["tags"] = epu.Tags +} + +// ElasticPoolOperation a elastic pool operation. +type ElasticPoolOperation struct { + // ElasticPoolOperationProperties - Resource properties. + *ElasticPoolOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperation. +func (epo ElasticPoolOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epo.ElasticPoolOperationProperties != nil { + objectMap["properties"] = epo.ElasticPoolOperationProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ElasticPoolUpdate struct. -func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ElasticPoolOperation struct. +func (epo *ElasticPoolOperation) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -6592,32 +6966,41 @@ func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "sku": + case "properties": if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) + var elasticPoolOperationProperties ElasticPoolOperationProperties + err = json.Unmarshal(*v, &elasticPoolOperationProperties) if err != nil { return err } - epu.Sku = &sku + epo.ElasticPoolOperationProperties = &elasticPoolOperationProperties } - case "properties": + case "id": if v != nil { - var elasticPoolUpdateProperties ElasticPoolUpdateProperties - err = json.Unmarshal(*v, &elasticPoolUpdateProperties) + var ID string + err = json.Unmarshal(*v, &ID) if err != nil { return err } - epu.ElasticPoolUpdateProperties = &elasticPoolUpdateProperties + epo.ID = &ID } - case "tags": + case "name": if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) + var name string + err = json.Unmarshal(*v, &name) if err != nil { return err } - epu.Tags = tags + epo.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epo.Type = &typeVar } } } @@ -6625,142 +7008,33 @@ func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { return nil } -// ElasticPoolUpdateProperties properties of an elastic pool -type ElasticPoolUpdateProperties struct { - // MaxSizeBytes - The storage limit for the database elastic pool in bytes. - MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` - // PerDatabaseSettings - The per database settings for the elastic pool. - PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` - // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' - LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` - // MaintenanceConfigurationID - Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. - MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` +// ElasticPoolOperationListResult the response to a list elastic pool operations request +type ElasticPoolOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPoolOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// EncryptionProtector the server encryption protector. -type EncryptionProtector struct { - autorest.Response `json:"-"` - // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. - Kind *string `json:"kind,omitempty"` - // Location - READ-ONLY; Resource location. - Location *string `json:"location,omitempty"` - // EncryptionProtectorProperties - Resource properties. - *EncryptionProtectorProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for EncryptionProtector. -func (ep EncryptionProtector) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ep.EncryptionProtectorProperties != nil { - objectMap["properties"] = ep.EncryptionProtectorProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for EncryptionProtector struct. -func (ep *EncryptionProtector) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "kind": - if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - ep.Kind = &kind - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ep.Location = &location - } - case "properties": - if v != nil { - var encryptionProtectorProperties EncryptionProtectorProperties - err = json.Unmarshal(*v, &encryptionProtectorProperties) - if err != nil { - return err - } - ep.EncryptionProtectorProperties = &encryptionProtectorProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ep.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ep.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ep.Type = &typeVar - } - } - } - - return nil -} - -// EncryptionProtectorListResult a list of server encryption protectors. -type EncryptionProtectorListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]EncryptionProtector `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for EncryptionProtectorListResult. -func (eplr EncryptionProtectorListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ElasticPoolOperationListResult. +func (epolr ElasticPoolOperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector +// ElasticPoolOperationListResultIterator provides access to a complete listing of ElasticPoolOperation // values. -type EncryptionProtectorListResultIterator struct { +type ElasticPoolOperationListResultIterator struct { i int - page EncryptionProtectorListResultPage + page ElasticPoolOperationListResultPage } // NextWithContext 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 *EncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ElasticPoolOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -6785,67 +7059,67 @@ func (iter *EncryptionProtectorListResultIterator) NextWithContext(ctx context.C // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *EncryptionProtectorListResultIterator) Next() error { +func (iter *ElasticPoolOperationListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter EncryptionProtectorListResultIterator) NotDone() bool { +func (iter ElasticPoolOperationListResultIterator) 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 EncryptionProtectorListResultIterator) Response() EncryptionProtectorListResult { +func (iter ElasticPoolOperationListResultIterator) Response() ElasticPoolOperationListResult { 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 EncryptionProtectorListResultIterator) Value() EncryptionProtector { +func (iter ElasticPoolOperationListResultIterator) Value() ElasticPoolOperation { if !iter.page.NotDone() { - return EncryptionProtector{} + return ElasticPoolOperation{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the EncryptionProtectorListResultIterator type. -func NewEncryptionProtectorListResultIterator(page EncryptionProtectorListResultPage) EncryptionProtectorListResultIterator { - return EncryptionProtectorListResultIterator{page: page} +// Creates a new instance of the ElasticPoolOperationListResultIterator type. +func NewElasticPoolOperationListResultIterator(page ElasticPoolOperationListResultPage) ElasticPoolOperationListResultIterator { + return ElasticPoolOperationListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (eplr EncryptionProtectorListResult) IsEmpty() bool { - return eplr.Value == nil || len(*eplr.Value) == 0 +func (epolr ElasticPoolOperationListResult) IsEmpty() bool { + return epolr.Value == nil || len(*epolr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (eplr EncryptionProtectorListResult) hasNextLink() bool { - return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +func (epolr ElasticPoolOperationListResult) hasNextLink() bool { + return epolr.NextLink != nil && len(*epolr.NextLink) != 0 } -// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// elasticPoolOperationListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { - if !eplr.hasNextLink() { +func (epolr ElasticPoolOperationListResult) elasticPoolOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !epolr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(eplr.NextLink))) + autorest.WithBaseURL(to.String(epolr.NextLink))) } -// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. -type EncryptionProtectorListResultPage struct { - fn func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error) - eplr EncryptionProtectorListResult +// ElasticPoolOperationListResultPage contains a page of ElasticPoolOperation values. +type ElasticPoolOperationListResultPage struct { + fn func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error) + epolr ElasticPoolOperationListResult } // NextWithContext 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 *EncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ElasticPoolOperationListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -6855,11 +7129,11 @@ func (page *EncryptionProtectorListResultPage) NextWithContext(ctx context.Conte }() } for { - next, err := page.fn(ctx, page.eplr) + next, err := page.fn(ctx, page.epolr) if err != nil { return err } - page.eplr = next + page.epolr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -6870,78 +7144,219 @@ func (page *EncryptionProtectorListResultPage) NextWithContext(ctx context.Conte // 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. // Deprecated: Use NextWithContext() instead. -func (page *EncryptionProtectorListResultPage) Next() error { +func (page *ElasticPoolOperationListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page EncryptionProtectorListResultPage) NotDone() bool { - return !page.eplr.IsEmpty() +func (page ElasticPoolOperationListResultPage) NotDone() bool { + return !page.epolr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page EncryptionProtectorListResultPage) Response() EncryptionProtectorListResult { - return page.eplr +func (page ElasticPoolOperationListResultPage) Response() ElasticPoolOperationListResult { + return page.epolr } // Values returns the slice of values for the current page or nil if there are no values. -func (page EncryptionProtectorListResultPage) Values() []EncryptionProtector { - if page.eplr.IsEmpty() { +func (page ElasticPoolOperationListResultPage) Values() []ElasticPoolOperation { + if page.epolr.IsEmpty() { return nil } - return *page.eplr.Value + return *page.epolr.Value } -// Creates a new instance of the EncryptionProtectorListResultPage type. -func NewEncryptionProtectorListResultPage(cur EncryptionProtectorListResult, getNextPage func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error)) EncryptionProtectorListResultPage { - return EncryptionProtectorListResultPage{ - fn: getNextPage, - eplr: cur, +// Creates a new instance of the ElasticPoolOperationListResultPage type. +func NewElasticPoolOperationListResultPage(cur ElasticPoolOperationListResult, getNextPage func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error)) ElasticPoolOperationListResultPage { + return ElasticPoolOperationListResultPage{ + fn: getNextPage, + epolr: cur, } } -// EncryptionProtectorProperties properties for an encryption protector execution. -type EncryptionProtectorProperties struct { - // Subregion - READ-ONLY; Subregion of the encryption protector. - Subregion *string `json:"subregion,omitempty"` - // ServerKeyName - The name of the server key. - ServerKeyName *string `json:"serverKeyName,omitempty"` - // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' - ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` - // URI - READ-ONLY; The URI of the server key. - URI *string `json:"uri,omitempty"` - // Thumbprint - READ-ONLY; Thumbprint of the server key. - Thumbprint *string `json:"thumbprint,omitempty"` - // AutoRotationEnabled - Key auto rotation opt-in flag. Either true or false. - AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` +// ElasticPoolOperationProperties the properties of a elastic pool operation. +type ElasticPoolOperationProperties struct { + // ElasticPoolName - READ-ONLY; The name of the elastic pool the operation is being performed on. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. + State *string `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` } -// MarshalJSON is the custom marshaler for EncryptionProtectorProperties. -func (epp EncryptionProtectorProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ElasticPoolOperationProperties. +func (epop ElasticPoolOperationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if epp.ServerKeyName != nil { - objectMap["serverKeyName"] = epp.ServerKeyName - } - if epp.ServerKeyType != "" { - objectMap["serverKeyType"] = epp.ServerKeyType - } - if epp.AutoRotationEnabled != nil { - objectMap["autoRotationEnabled"] = epp.AutoRotationEnabled - } return json.Marshal(objectMap) } -// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type EncryptionProtectorsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(EncryptionProtectorsClient) (EncryptionProtector, error) +// ElasticPoolPerDatabaseMaxPerformanceLevelCapability the max per-database performance level capability. +type ElasticPoolPerDatabaseMaxPerformanceLevelCapability struct { + // Limit - READ-ONLY; The maximum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // SupportedPerDatabaseMinPerformanceLevels - READ-ONLY; The list of supported min database performance levels. + SupportedPerDatabaseMinPerformanceLevels *[]ElasticPoolPerDatabaseMinPerformanceLevelCapability `json:"supportedPerDatabaseMinPerformanceLevels,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *EncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMaxPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMaxPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMinPerformanceLevelCapability the minimum per-database performance level +// capability. +type ElasticPoolPerDatabaseMinPerformanceLevelCapability struct { + // Limit - READ-ONLY; The minimum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMinPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMinPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseSettings per database settings of an elastic pool. +type ElasticPoolPerDatabaseSettings struct { + // MinCapacity - The minimum capacity all databases are guaranteed. + MinCapacity *float64 `json:"minCapacity,omitempty"` + // MaxCapacity - The maximum capacity any one database can consume. + MaxCapacity *float64 `json:"maxCapacity,omitempty"` +} + +// ElasticPoolPerformanceLevelCapability the Elastic Pool performance level capability. +type ElasticPoolPerformanceLevelCapability struct { + // PerformanceLevel - READ-ONLY; The performance level for the pool. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // MaxDatabaseCount - READ-ONLY; The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size for this performance level. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - READ-ONLY; The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeRangeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxPerformanceLevels - READ-ONLY; The list of supported per database max performance levels. + SupportedPerDatabaseMaxPerformanceLevels *[]ElasticPoolPerDatabaseMaxPerformanceLevelCapability `json:"supportedPerDatabaseMaxPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the performance level. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations + SupportedMaintenanceConfigurations *[]MaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerformanceLevelCapability. +func (epplc ElasticPoolPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epplc.Reason != nil { + objectMap["reason"] = epplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolProperties properties of an elastic pool +type ElasticPoolProperties struct { + // State - READ-ONLY; The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' + State ElasticPoolState `json:"state,omitempty"` + // CreationDate - READ-ONLY; The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` + // MaintenanceConfigurationID - Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // HighAvailabilityReplicaCount - The number of secondary replicas associated with the elastic pool that are used to provide high availability. + HighAvailabilityReplicaCount *int32 `json:"highAvailabilityReplicaCount,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolProperties. +func (epp ElasticPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = epp.MaxSizeBytes + } + if epp.PerDatabaseSettings != nil { + objectMap["perDatabaseSettings"] = epp.PerDatabaseSettings + } + if epp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = epp.ZoneRedundant + } + if epp.LicenseType != "" { + objectMap["licenseType"] = epp.LicenseType + } + if epp.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = epp.MaintenanceConfigurationID + } + if epp.HighAvailabilityReplicaCount != nil { + objectMap["highAvailabilityReplicaCount"] = epp.HighAvailabilityReplicaCount + } + return json.Marshal(objectMap) +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -6951,40 +7366,40 @@ func (future *EncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byt return nil } -// result is the default implementation for EncryptionProtectorsCreateOrUpdateFuture.Result. -func (future *EncryptionProtectorsCreateOrUpdateFuture) result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { +// result is the default implementation for ElasticPoolsCreateOrUpdateFuture.Result. +func (future *ElasticPoolsCreateOrUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { ep.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { ep, err = client.CreateOrUpdateResponder(ep.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") } } return } -// EncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type EncryptionProtectorsRevalidateFuture struct { +// ElasticPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsDeleteFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(EncryptionProtectorsClient) (autorest.Response, error) + Result func(ElasticPoolsClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *EncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { +func (future *ElasticPoolsDeleteFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -6994,89 +7409,255 @@ func (future *EncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) e return nil } -// result is the default implementation for EncryptionProtectorsRevalidateFuture.Result. -func (future *EncryptionProtectorsRevalidateFuture) result(client EncryptionProtectorsClient) (ar autorest.Response, err error) { +// result is the default implementation for ElasticPoolsDeleteFuture.Result. +func (future *ElasticPoolsDeleteFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsRevalidateFuture") + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsDeleteFuture") return } ar.Response = future.Response() return } -// ExportDatabaseDefinition contains the information necessary to perform export database operation. -type ExportDatabaseDefinition struct { - // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' - StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` - // StorageKey - Storage key. - StorageKey *string `json:"storageKey,omitempty"` - // StorageURI - Storage Uri. - StorageURI *string `json:"storageUri,omitempty"` - // AdministratorLogin - Administrator login name. - AdministratorLogin *string `json:"administratorLogin,omitempty"` - // AdministratorLoginPassword - Administrator login password. - AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` - // AuthenticationType - Authentication type. - AuthenticationType *string `json:"authenticationType,omitempty"` - // NetworkIsolation - Optional resource information to enable network isolation for request. - NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +// ElasticPoolsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (autorest.Response, error) } -// ExtendedDatabaseBlobAuditingPolicy an extended database blob auditing policy. -type ExtendedDatabaseBlobAuditingPolicy struct { - autorest.Response `json:"-"` - // ExtendedDatabaseBlobAuditingPolicyProperties - Resource properties. - *ExtendedDatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicy. -func (edbap ExtendedDatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if edbap.ExtendedDatabaseBlobAuditingPolicyProperties != nil { - objectMap["properties"] = edbap.ExtendedDatabaseBlobAuditingPolicyProperties +// result is the default implementation for ElasticPoolsFailoverFuture.Result. +func (future *ElasticPoolsFailoverFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsFailoverFuture", "Result", future.Response(), "Polling failure") + return } - return json.Marshal(objectMap) + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsFailoverFuture") + return + } + ar.Response = future.Response() + return } -// UnmarshalJSON is the custom unmarshaler for ExtendedDatabaseBlobAuditingPolicy struct. -func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { return err } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var extendedDatabaseBlobAuditingPolicyProperties ExtendedDatabaseBlobAuditingPolicyProperties - err = json.Unmarshal(*v, &extendedDatabaseBlobAuditingPolicyProperties) - if err != nil { - return err - } - edbap.ExtendedDatabaseBlobAuditingPolicyProperties = &extendedDatabaseBlobAuditingPolicyProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - edbap.ID = &ID + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsUpdateFuture.Result. +func (future *ElasticPoolsUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.UpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolUpdate an elastic pool update. +type ElasticPoolUpdate struct { + Sku *Sku `json:"sku,omitempty"` + // ElasticPoolUpdateProperties - Resource properties. + *ElasticPoolUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolUpdate. +func (epu ElasticPoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epu.Sku != nil { + objectMap["sku"] = epu.Sku + } + if epu.ElasticPoolUpdateProperties != nil { + objectMap["properties"] = epu.ElasticPoolUpdateProperties + } + if epu.Tags != nil { + objectMap["tags"] = epu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolUpdate struct. +func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + epu.Sku = &sku + } + case "properties": + if v != nil { + var elasticPoolUpdateProperties ElasticPoolUpdateProperties + err = json.Unmarshal(*v, &elasticPoolUpdateProperties) + if err != nil { + return err + } + epu.ElasticPoolUpdateProperties = &elasticPoolUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + epu.Tags = tags + } + } + } + + return nil +} + +// ElasticPoolUpdateProperties properties of an elastic pool +type ElasticPoolUpdateProperties struct { + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` + // MaintenanceConfigurationID - Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // HighAvailabilityReplicaCount - The number of secondary replicas associated with the elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic pools. + HighAvailabilityReplicaCount *int32 `json:"highAvailabilityReplicaCount,omitempty"` +} + +// EncryptionProtector the server encryption protector. +type EncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // EncryptionProtectorProperties - Resource properties. + *EncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtector. +func (ep EncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.EncryptionProtectorProperties != nil { + objectMap["properties"] = ep.EncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EncryptionProtector struct. +func (ep *EncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "properties": + if v != nil { + var encryptionProtectorProperties EncryptionProtectorProperties + err = json.Unmarshal(*v, &encryptionProtectorProperties) + if err != nil { + return err + } + ep.EncryptionProtectorProperties = &encryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID } case "name": if v != nil { @@ -7085,7 +7666,7 @@ func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) erro if err != nil { return err } - edbap.Name = &name + ep.Name = &name } case "type": if v != nil { @@ -7094,7 +7675,7 @@ func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) erro if err != nil { return err } - edbap.Type = &typeVar + ep.Type = &typeVar } } } @@ -7102,33 +7683,33 @@ func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) erro return nil } -// ExtendedDatabaseBlobAuditingPolicyListResult a list of database extended auditing settings. -type ExtendedDatabaseBlobAuditingPolicyListResult struct { +// EncryptionProtectorListResult a list of server encryption protectors. +type EncryptionProtectorListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ExtendedDatabaseBlobAuditingPolicy `json:"value,omitempty"` + Value *[]EncryptionProtector `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicyListResult. -func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for EncryptionProtectorListResult. +func (eplr EncryptionProtectorListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ExtendedDatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of -// ExtendedDatabaseBlobAuditingPolicy values. -type ExtendedDatabaseBlobAuditingPolicyListResultIterator struct { +// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector +// values. +type EncryptionProtectorListResultIterator struct { i int - page ExtendedDatabaseBlobAuditingPolicyListResultPage + page EncryptionProtectorListResultPage } // NextWithContext 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 *ExtendedDatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *EncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -7153,68 +7734,67 @@ func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) NextWithContex // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) Next() error { +func (iter *EncryptionProtectorListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) NotDone() bool { +func (iter EncryptionProtectorListResultIterator) 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 ExtendedDatabaseBlobAuditingPolicyListResultIterator) Response() ExtendedDatabaseBlobAuditingPolicyListResult { +func (iter EncryptionProtectorListResultIterator) Response() EncryptionProtectorListResult { 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 ExtendedDatabaseBlobAuditingPolicyListResultIterator) Value() ExtendedDatabaseBlobAuditingPolicy { +func (iter EncryptionProtectorListResultIterator) Value() EncryptionProtector { if !iter.page.NotDone() { - return ExtendedDatabaseBlobAuditingPolicy{} + return EncryptionProtector{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultIterator type. -func NewExtendedDatabaseBlobAuditingPolicyListResultIterator(page ExtendedDatabaseBlobAuditingPolicyListResultPage) ExtendedDatabaseBlobAuditingPolicyListResultIterator { - return ExtendedDatabaseBlobAuditingPolicyListResultIterator{page: page} +// Creates a new instance of the EncryptionProtectorListResultIterator type. +func NewEncryptionProtectorListResultIterator(page EncryptionProtectorListResultPage) EncryptionProtectorListResultIterator { + return EncryptionProtectorListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) IsEmpty() bool { - return edbaplr.Value == nil || len(*edbaplr.Value) == 0 +func (eplr EncryptionProtectorListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) hasNextLink() bool { - return edbaplr.NextLink != nil && len(*edbaplr.NextLink) != 0 +func (eplr EncryptionProtectorListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 } -// extendedDatabaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) extendedDatabaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !edbaplr.hasNextLink() { +func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(edbaplr.NextLink))) + autorest.WithBaseURL(to.String(eplr.NextLink))) } -// ExtendedDatabaseBlobAuditingPolicyListResultPage contains a page of ExtendedDatabaseBlobAuditingPolicy -// values. -type ExtendedDatabaseBlobAuditingPolicyListResultPage struct { - fn func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error) - edbaplr ExtendedDatabaseBlobAuditingPolicyListResult +// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. +type EncryptionProtectorListResultPage struct { + fn func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error) + eplr EncryptionProtectorListResult } // NextWithContext 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 *ExtendedDatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *EncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -7224,11 +7804,11 @@ func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) NextWithContext(ct }() } for { - next, err := page.fn(ctx, page.edbaplr) + next, err := page.fn(ctx, page.eplr) if err != nil { return err } - page.edbaplr = next + page.eplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -7239,143 +7819,78 @@ func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) NextWithContext(ct // 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. // Deprecated: Use NextWithContext() instead. -func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) Next() error { +func (page *EncryptionProtectorListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) NotDone() bool { - return !page.edbaplr.IsEmpty() +func (page EncryptionProtectorListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Response() ExtendedDatabaseBlobAuditingPolicyListResult { - return page.edbaplr +func (page EncryptionProtectorListResultPage) Response() EncryptionProtectorListResult { + return page.eplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Values() []ExtendedDatabaseBlobAuditingPolicy { - if page.edbaplr.IsEmpty() { +func (page EncryptionProtectorListResultPage) Values() []EncryptionProtector { + if page.eplr.IsEmpty() { return nil } - return *page.edbaplr.Value + return *page.eplr.Value } -// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultPage type. -func NewExtendedDatabaseBlobAuditingPolicyListResultPage(cur ExtendedDatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error)) ExtendedDatabaseBlobAuditingPolicyListResultPage { - return ExtendedDatabaseBlobAuditingPolicyListResultPage{ - fn: getNextPage, - edbaplr: cur, +// Creates a new instance of the EncryptionProtectorListResultPage type. +func NewEncryptionProtectorListResultPage(cur EncryptionProtectorListResult, getNextPage func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error)) EncryptionProtectorListResultPage { + return EncryptionProtectorListResultPage{ + fn: getNextPage, + eplr: cur, } } -// ExtendedDatabaseBlobAuditingPolicyProperties properties of an extended database blob auditing policy. -type ExtendedDatabaseBlobAuditingPolicyProperties struct { - // PredicateExpression - Specifies condition of where clause when creating an audit. - PredicateExpression *string `json:"predicateExpression,omitempty"` - // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. - RetentionDays *int32 `json:"retentionDays,omitempty"` - // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. - // - // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - // - // BATCH_COMPLETED_GROUP, - // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - // FAILED_DATABASE_AUTHENTICATION_GROUP. - // - // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - // - // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - // - // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - // BACKUP_RESTORE_GROUP - // DATABASE_LOGOUT_GROUP - // DATABASE_OBJECT_CHANGE_GROUP - // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - // DATABASE_OPERATION_GROUP - // DATABASE_PERMISSION_CHANGE_GROUP - // DATABASE_PRINCIPAL_CHANGE_GROUP - // DATABASE_PRINCIPAL_IMPERSONATION_GROUP - // DATABASE_ROLE_MEMBER_CHANGE_GROUP - // FAILED_DATABASE_AUTHENTICATION_GROUP - // SCHEMA_OBJECT_ACCESS_GROUP - // SCHEMA_OBJECT_CHANGE_GROUP - // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - // USER_CHANGE_PASSWORD_GROUP - // BATCH_STARTED_GROUP - // BATCH_COMPLETED_GROUP - // - // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - // - // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). - // - // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: - // SELECT - // UPDATE - // INSERT - // DELETE - // EXECUTE - // RECEIVE - // REFERENCES - // - // The general form for defining an action to be audited is: - // {action} ON {object} BY {principal} - // - // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - // - // For example: - // SELECT on dbo.myTable by public - // SELECT on DATABASE::myDatabase by public - // SELECT on SCHEMA::mySchema by public - // - // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) - AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` - // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. - IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` - // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. - // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. - // - // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. - // Note that for server level audit you should use the 'master' database as {databaseName}. - // - // Diagnostic Settings URI format: - // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - // - // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) - // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) - IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` - // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. - // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` - // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' - State BlobAuditingPolicyState `json:"state,omitempty"` - // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - StorageEndpoint *string `json:"storageEndpoint,omitempty"` - // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. - // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. - // Prerequisites for using managed identity authentication: - // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. - // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) - StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` - // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. - StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +// EncryptionProtectorProperties properties for an encryption protector execution. +type EncryptionProtectorProperties struct { + // Subregion - READ-ONLY; Subregion of the encryption protector. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyName - The name of the server key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // AutoRotationEnabled - Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` } -// ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture struct { +// MarshalJSON is the custom marshaler for EncryptionProtectorProperties. +func (epp EncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.ServerKeyName != nil { + objectMap["serverKeyName"] = epp.ServerKeyName + } + if epp.ServerKeyType != "" { + objectMap["serverKeyType"] = epp.ServerKeyType + } + if epp.AutoRotationEnabled != nil { + objectMap["autoRotationEnabled"] = epp.AutoRotationEnabled + } + return json.Marshal(objectMap) +} + +// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ExtendedServerBlobAuditingPoliciesClient) (ExtendedServerBlobAuditingPolicy, error) + Result func(EncryptionProtectorsClient) (EncryptionProtector, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *EncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -7385,34 +7900,71 @@ func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJ return nil } -// result is the default implementation for ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture.Result. -func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) result(client ExtendedServerBlobAuditingPoliciesClient) (esbap ExtendedServerBlobAuditingPolicy, err error) { +// result is the default implementation for EncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *EncryptionProtectorsCreateOrUpdateFuture) result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - esbap.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture") + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if esbap.Response.Response, err = future.GetResult(sender); err == nil && esbap.Response.Response.StatusCode != http.StatusNoContent { - esbap, err = client.CreateOrUpdateResponder(esbap.Response.Response) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", esbap.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") } } return } -// ExtendedServerBlobAuditingPolicy an extended server blob auditing policy. -type ExtendedServerBlobAuditingPolicy struct { +// EncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsRevalidateFuture.Result. +func (future *EncryptionProtectorsRevalidateFuture) result(client EncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// EndpointCertificate certificate used on an endpoint on the Managed Instance. +type EndpointCertificate struct { autorest.Response `json:"-"` - // ExtendedServerBlobAuditingPolicyProperties - Resource properties. - *ExtendedServerBlobAuditingPolicyProperties `json:"properties,omitempty"` + // EndpointCertificateProperties - Resource properties. + *EndpointCertificateProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -7421,17 +7973,17 @@ type ExtendedServerBlobAuditingPolicy struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicy. -func (esbap ExtendedServerBlobAuditingPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for EndpointCertificate. +func (ec EndpointCertificate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if esbap.ExtendedServerBlobAuditingPolicyProperties != nil { - objectMap["properties"] = esbap.ExtendedServerBlobAuditingPolicyProperties + if ec.EndpointCertificateProperties != nil { + objectMap["properties"] = ec.EndpointCertificateProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ExtendedServerBlobAuditingPolicy struct. -func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for EndpointCertificate struct. +func (ec *EndpointCertificate) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -7441,12 +7993,12 @@ func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error switch k { case "properties": if v != nil { - var extendedServerBlobAuditingPolicyProperties ExtendedServerBlobAuditingPolicyProperties - err = json.Unmarshal(*v, &extendedServerBlobAuditingPolicyProperties) + var endpointCertificateProperties EndpointCertificateProperties + err = json.Unmarshal(*v, &endpointCertificateProperties) if err != nil { return err } - esbap.ExtendedServerBlobAuditingPolicyProperties = &extendedServerBlobAuditingPolicyProperties + ec.EndpointCertificateProperties = &endpointCertificateProperties } case "id": if v != nil { @@ -7455,7 +8007,7 @@ func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error if err != nil { return err } - esbap.ID = &ID + ec.ID = &ID } case "name": if v != nil { @@ -7464,7 +8016,7 @@ func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error if err != nil { return err } - esbap.Name = &name + ec.Name = &name } case "type": if v != nil { @@ -7473,7 +8025,7 @@ func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error if err != nil { return err } - esbap.Type = &typeVar + ec.Type = &typeVar } } } @@ -7481,33 +8033,33 @@ func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error return nil } -// ExtendedServerBlobAuditingPolicyListResult a list of server extended auditing settings. -type ExtendedServerBlobAuditingPolicyListResult struct { +// EndpointCertificateListResult a list of endpoint certificates on the target instance. +type EndpointCertificateListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ExtendedServerBlobAuditingPolicy `json:"value,omitempty"` + Value *[]EndpointCertificate `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicyListResult. -func (esbaplr ExtendedServerBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for EndpointCertificateListResult. +func (eclr EndpointCertificateListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ExtendedServerBlobAuditingPolicyListResultIterator provides access to a complete listing of -// ExtendedServerBlobAuditingPolicy values. -type ExtendedServerBlobAuditingPolicyListResultIterator struct { +// EndpointCertificateListResultIterator provides access to a complete listing of EndpointCertificate +// values. +type EndpointCertificateListResultIterator struct { i int - page ExtendedServerBlobAuditingPolicyListResultPage + page EndpointCertificateListResultPage } // NextWithContext 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 *ExtendedServerBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *EndpointCertificateListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointCertificateListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -7532,68 +8084,67 @@ func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) NextWithContext( // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) Next() error { +func (iter *EndpointCertificateListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ExtendedServerBlobAuditingPolicyListResultIterator) NotDone() bool { +func (iter EndpointCertificateListResultIterator) 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 ExtendedServerBlobAuditingPolicyListResultIterator) Response() ExtendedServerBlobAuditingPolicyListResult { +func (iter EndpointCertificateListResultIterator) Response() EndpointCertificateListResult { 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 ExtendedServerBlobAuditingPolicyListResultIterator) Value() ExtendedServerBlobAuditingPolicy { +func (iter EndpointCertificateListResultIterator) Value() EndpointCertificate { if !iter.page.NotDone() { - return ExtendedServerBlobAuditingPolicy{} + return EndpointCertificate{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultIterator type. -func NewExtendedServerBlobAuditingPolicyListResultIterator(page ExtendedServerBlobAuditingPolicyListResultPage) ExtendedServerBlobAuditingPolicyListResultIterator { - return ExtendedServerBlobAuditingPolicyListResultIterator{page: page} +// Creates a new instance of the EndpointCertificateListResultIterator type. +func NewEndpointCertificateListResultIterator(page EndpointCertificateListResultPage) EndpointCertificateListResultIterator { + return EndpointCertificateListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (esbaplr ExtendedServerBlobAuditingPolicyListResult) IsEmpty() bool { - return esbaplr.Value == nil || len(*esbaplr.Value) == 0 +func (eclr EndpointCertificateListResult) IsEmpty() bool { + return eclr.Value == nil || len(*eclr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (esbaplr ExtendedServerBlobAuditingPolicyListResult) hasNextLink() bool { - return esbaplr.NextLink != nil && len(*esbaplr.NextLink) != 0 +func (eclr EndpointCertificateListResult) hasNextLink() bool { + return eclr.NextLink != nil && len(*eclr.NextLink) != 0 } -// extendedServerBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// endpointCertificateListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (esbaplr ExtendedServerBlobAuditingPolicyListResult) extendedServerBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !esbaplr.hasNextLink() { +func (eclr EndpointCertificateListResult) endpointCertificateListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eclr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(esbaplr.NextLink))) + autorest.WithBaseURL(to.String(eclr.NextLink))) } -// ExtendedServerBlobAuditingPolicyListResultPage contains a page of ExtendedServerBlobAuditingPolicy -// values. -type ExtendedServerBlobAuditingPolicyListResultPage struct { - fn func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error) - esbaplr ExtendedServerBlobAuditingPolicyListResult +// EndpointCertificateListResultPage contains a page of EndpointCertificate values. +type EndpointCertificateListResultPage struct { + fn func(context.Context, EndpointCertificateListResult) (EndpointCertificateListResult, error) + eclr EndpointCertificateListResult } // NextWithContext 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 *ExtendedServerBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *EndpointCertificateListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointCertificateListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -7603,11 +8154,11 @@ func (page *ExtendedServerBlobAuditingPolicyListResultPage) NextWithContext(ctx }() } for { - next, err := page.fn(ctx, page.esbaplr) + next, err := page.fn(ctx, page.eclr) if err != nil { return err } - page.esbaplr = next + page.eclr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -7618,152 +8169,65 @@ func (page *ExtendedServerBlobAuditingPolicyListResultPage) NextWithContext(ctx // 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. // Deprecated: Use NextWithContext() instead. -func (page *ExtendedServerBlobAuditingPolicyListResultPage) Next() error { +func (page *EndpointCertificateListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ExtendedServerBlobAuditingPolicyListResultPage) NotDone() bool { - return !page.esbaplr.IsEmpty() +func (page EndpointCertificateListResultPage) NotDone() bool { + return !page.eclr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ExtendedServerBlobAuditingPolicyListResultPage) Response() ExtendedServerBlobAuditingPolicyListResult { - return page.esbaplr +func (page EndpointCertificateListResultPage) Response() EndpointCertificateListResult { + return page.eclr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ExtendedServerBlobAuditingPolicyListResultPage) Values() []ExtendedServerBlobAuditingPolicy { - if page.esbaplr.IsEmpty() { +func (page EndpointCertificateListResultPage) Values() []EndpointCertificate { + if page.eclr.IsEmpty() { return nil } - return *page.esbaplr.Value + return *page.eclr.Value } -// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultPage type. -func NewExtendedServerBlobAuditingPolicyListResultPage(cur ExtendedServerBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error)) ExtendedServerBlobAuditingPolicyListResultPage { - return ExtendedServerBlobAuditingPolicyListResultPage{ - fn: getNextPage, - esbaplr: cur, +// Creates a new instance of the EndpointCertificateListResultPage type. +func NewEndpointCertificateListResultPage(cur EndpointCertificateListResult, getNextPage func(context.Context, EndpointCertificateListResult) (EndpointCertificateListResult, error)) EndpointCertificateListResultPage { + return EndpointCertificateListResultPage{ + fn: getNextPage, + eclr: cur, } } -// ExtendedServerBlobAuditingPolicyProperties properties of an extended server blob auditing policy. -type ExtendedServerBlobAuditingPolicyProperties struct { - // IsDevopsAuditEnabled - Specifies the state of devops audit. If state is Enabled, devops logs will be sent to Azure Monitor. - // In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - // - // When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. - // - // Diagnostic Settings URI format: - // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - // - // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) - // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) - IsDevopsAuditEnabled *bool `json:"isDevopsAuditEnabled,omitempty"` - // PredicateExpression - Specifies condition of where clause when creating an audit. - PredicateExpression *string `json:"predicateExpression,omitempty"` - // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. - RetentionDays *int32 `json:"retentionDays,omitempty"` - // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. - // - // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - // - // BATCH_COMPLETED_GROUP, - // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - // FAILED_DATABASE_AUTHENTICATION_GROUP. - // - // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - // - // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - // - // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - // BACKUP_RESTORE_GROUP - // DATABASE_LOGOUT_GROUP - // DATABASE_OBJECT_CHANGE_GROUP - // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - // DATABASE_OPERATION_GROUP - // DATABASE_PERMISSION_CHANGE_GROUP - // DATABASE_PRINCIPAL_CHANGE_GROUP - // DATABASE_PRINCIPAL_IMPERSONATION_GROUP - // DATABASE_ROLE_MEMBER_CHANGE_GROUP - // FAILED_DATABASE_AUTHENTICATION_GROUP - // SCHEMA_OBJECT_ACCESS_GROUP - // SCHEMA_OBJECT_CHANGE_GROUP - // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - // USER_CHANGE_PASSWORD_GROUP - // BATCH_STARTED_GROUP - // BATCH_COMPLETED_GROUP - // - // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - // - // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). - // - // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: - // SELECT - // UPDATE - // INSERT - // DELETE - // EXECUTE - // RECEIVE - // REFERENCES - // - // The general form for defining an action to be audited is: - // {action} ON {object} BY {principal} - // - // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - // - // For example: - // SELECT on dbo.myTable by public - // SELECT on DATABASE::myDatabase by public - // SELECT on SCHEMA::mySchema by public - // - // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) - AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` - // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. - IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` - // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. - // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. - // - // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. - // Note that for server level audit you should use the 'master' database as {databaseName}. - // - // Diagnostic Settings URI format: - // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - // - // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) - // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) - IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` - // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. - // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` - // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' - State BlobAuditingPolicyState `json:"state,omitempty"` - // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. - StorageEndpoint *string `json:"storageEndpoint,omitempty"` - // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. - // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. - // Prerequisites for using managed identity authentication: - // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. - // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) - StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` - // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. - StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +// EndpointCertificateProperties the properties of an endpoint certificate. +type EndpointCertificateProperties struct { + // PublicBlob - The certificate public blob + PublicBlob *string `json:"publicBlob,omitempty"` } -// FailoverGroup a failover group. -type FailoverGroup struct { +// ExportDatabaseDefinition contains the information necessary to perform export database operation. +type ExportDatabaseDefinition struct { + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// ExtendedDatabaseBlobAuditingPolicy an extended database blob auditing policy. +type ExtendedDatabaseBlobAuditingPolicy struct { autorest.Response `json:"-"` - // Location - READ-ONLY; Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // FailoverGroupProperties - Resource properties. - *FailoverGroupProperties `json:"properties,omitempty"` + // ExtendedDatabaseBlobAuditingPolicyProperties - Resource properties. + *ExtendedDatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -7772,20 +8236,17 @@ type FailoverGroup struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for FailoverGroup. -func (fg FailoverGroup) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicy. +func (edbap ExtendedDatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if fg.Tags != nil { - objectMap["tags"] = fg.Tags - } - if fg.FailoverGroupProperties != nil { - objectMap["properties"] = fg.FailoverGroupProperties + if edbap.ExtendedDatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = edbap.ExtendedDatabaseBlobAuditingPolicyProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for FailoverGroup struct. -func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ExtendedDatabaseBlobAuditingPolicy struct. +func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -7793,32 +8254,14 @@ func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - fg.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - fg.Tags = tags - } case "properties": if v != nil { - var failoverGroupProperties FailoverGroupProperties - err = json.Unmarshal(*v, &failoverGroupProperties) + var extendedDatabaseBlobAuditingPolicyProperties ExtendedDatabaseBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &extendedDatabaseBlobAuditingPolicyProperties) if err != nil { return err } - fg.FailoverGroupProperties = &failoverGroupProperties + edbap.ExtendedDatabaseBlobAuditingPolicyProperties = &extendedDatabaseBlobAuditingPolicyProperties } case "id": if v != nil { @@ -7827,7 +8270,7 @@ func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { if err != nil { return err } - fg.ID = &ID + edbap.ID = &ID } case "name": if v != nil { @@ -7836,7 +8279,7 @@ func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { if err != nil { return err } - fg.Name = &name + edbap.Name = &name } case "type": if v != nil { @@ -7845,7 +8288,7 @@ func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { if err != nil { return err } - fg.Type = &typeVar + edbap.Type = &typeVar } } } @@ -7853,32 +8296,33 @@ func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { return nil } -// FailoverGroupListResult a list of failover groups. -type FailoverGroupListResult struct { +// ExtendedDatabaseBlobAuditingPolicyListResult a list of database extended auditing settings. +type ExtendedDatabaseBlobAuditingPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]FailoverGroup `json:"value,omitempty"` + Value *[]ExtendedDatabaseBlobAuditingPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for FailoverGroupListResult. -func (fglr FailoverGroupListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicyListResult. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. -type FailoverGroupListResultIterator struct { +// ExtendedDatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ExtendedDatabaseBlobAuditingPolicy values. +type ExtendedDatabaseBlobAuditingPolicyListResultIterator struct { i int - page FailoverGroupListResultPage + page ExtendedDatabaseBlobAuditingPolicyListResultPage } // NextWithContext 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 *FailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -7903,67 +8347,68 @@ func (iter *FailoverGroupListResultIterator) NextWithContext(ctx context.Context // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *FailoverGroupListResultIterator) Next() error { +func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter FailoverGroupListResultIterator) NotDone() bool { +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) 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 FailoverGroupListResultIterator) Response() FailoverGroupListResult { +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) Response() ExtendedDatabaseBlobAuditingPolicyListResult { 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 FailoverGroupListResultIterator) Value() FailoverGroup { +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) Value() ExtendedDatabaseBlobAuditingPolicy { if !iter.page.NotDone() { - return FailoverGroup{} + return ExtendedDatabaseBlobAuditingPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the FailoverGroupListResultIterator type. -func NewFailoverGroupListResultIterator(page FailoverGroupListResultPage) FailoverGroupListResultIterator { - return FailoverGroupListResultIterator{page: page} +// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultIterator type. +func NewExtendedDatabaseBlobAuditingPolicyListResultIterator(page ExtendedDatabaseBlobAuditingPolicyListResultPage) ExtendedDatabaseBlobAuditingPolicyListResultIterator { + return ExtendedDatabaseBlobAuditingPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (fglr FailoverGroupListResult) IsEmpty() bool { - return fglr.Value == nil || len(*fglr.Value) == 0 +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) IsEmpty() bool { + return edbaplr.Value == nil || len(*edbaplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (fglr FailoverGroupListResult) hasNextLink() bool { - return fglr.NextLink != nil && len(*fglr.NextLink) != 0 +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) hasNextLink() bool { + return edbaplr.NextLink != nil && len(*edbaplr.NextLink) != 0 } -// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// extendedDatabaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (fglr FailoverGroupListResult) failoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !fglr.hasNextLink() { +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) extendedDatabaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !edbaplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(fglr.NextLink))) + autorest.WithBaseURL(to.String(edbaplr.NextLink))) } -// FailoverGroupListResultPage contains a page of FailoverGroup values. -type FailoverGroupListResultPage struct { - fn func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error) - fglr FailoverGroupListResult +// ExtendedDatabaseBlobAuditingPolicyListResultPage contains a page of ExtendedDatabaseBlobAuditingPolicy +// values. +type ExtendedDatabaseBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error) + edbaplr ExtendedDatabaseBlobAuditingPolicyListResult } // NextWithContext 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 *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -7973,11 +8418,11 @@ func (page *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (e }() } for { - next, err := page.fn(ctx, page.fglr) + next, err := page.fn(ctx, page.edbaplr) if err != nil { return err } - page.fglr = next + page.edbaplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -7988,95 +8433,149 @@ func (page *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (e // 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. // Deprecated: Use NextWithContext() instead. -func (page *FailoverGroupListResultPage) Next() error { +func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page FailoverGroupListResultPage) NotDone() bool { - return !page.fglr.IsEmpty() +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.edbaplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page FailoverGroupListResultPage) Response() FailoverGroupListResult { - return page.fglr +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Response() ExtendedDatabaseBlobAuditingPolicyListResult { + return page.edbaplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page FailoverGroupListResultPage) Values() []FailoverGroup { - if page.fglr.IsEmpty() { +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Values() []ExtendedDatabaseBlobAuditingPolicy { + if page.edbaplr.IsEmpty() { return nil } - return *page.fglr.Value -} - -// Creates a new instance of the FailoverGroupListResultPage type. -func NewFailoverGroupListResultPage(cur FailoverGroupListResult, getNextPage func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error)) FailoverGroupListResultPage { - return FailoverGroupListResultPage{ - fn: getNextPage, - fglr: cur, - } -} - -// FailoverGroupProperties properties of a failover group. -type FailoverGroupProperties struct { - // ReadWriteEndpoint - Read-write endpoint of the failover group instance. - ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` - // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. - ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` - // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'FailoverGroupReplicationRolePrimary', 'FailoverGroupReplicationRoleSecondary' - ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` - // ReplicationState - READ-ONLY; Replication state of the failover group instance. - ReplicationState *string `json:"replicationState,omitempty"` - // PartnerServers - List of partner server information for the failover group. - PartnerServers *[]PartnerInfo `json:"partnerServers,omitempty"` - // Databases - List of databases in the failover group. - Databases *[]string `json:"databases,omitempty"` + return *page.edbaplr.Value } -// MarshalJSON is the custom marshaler for FailoverGroupProperties. -func (fgp FailoverGroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if fgp.ReadWriteEndpoint != nil { - objectMap["readWriteEndpoint"] = fgp.ReadWriteEndpoint - } - if fgp.ReadOnlyEndpoint != nil { - objectMap["readOnlyEndpoint"] = fgp.ReadOnlyEndpoint - } - if fgp.PartnerServers != nil { - objectMap["partnerServers"] = fgp.PartnerServers - } - if fgp.Databases != nil { - objectMap["databases"] = fgp.Databases +// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultPage type. +func NewExtendedDatabaseBlobAuditingPolicyListResultPage(cur ExtendedDatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error)) ExtendedDatabaseBlobAuditingPolicyListResultPage { + return ExtendedDatabaseBlobAuditingPolicyListResultPage{ + fn: getNextPage, + edbaplr: cur, } - return json.Marshal(objectMap) -} - -// FailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. -type FailoverGroupReadOnlyEndpoint struct { - // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' - FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` } -// FailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. -type FailoverGroupReadWriteEndpoint struct { - // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'ReadWriteEndpointFailoverPolicyManual', 'ReadWriteEndpointFailoverPolicyAutomatic' - FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` - // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. - FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +// ExtendedDatabaseBlobAuditingPolicyProperties properties of an extended database blob auditing policy. +type ExtendedDatabaseBlobAuditingPolicyProperties struct { + // PredicateExpression - Specifies condition of where clause when creating an audit. + PredicateExpression *string `json:"predicateExpression,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // LEDGER_OPERATION_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // IsManagedIdentityInUse - Specifies whether Managed Identity is used to access blob storage + IsManagedIdentityInUse *bool `json:"isManagedIdentityInUse,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` } -// FailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type FailoverGroupsCreateOrUpdateFuture struct { +// ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(FailoverGroupsClient) (FailoverGroup, error) + Result func(ExtendedServerBlobAuditingPoliciesClient) (ExtendedServerBlobAuditingPolicy, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *FailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -8086,300 +8585,68 @@ func (future *FailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) err return nil } -// result is the default implementation for FailoverGroupsCreateOrUpdateFuture.Result. -func (future *FailoverGroupsCreateOrUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { +// result is the default implementation for ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture.Result. +func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) result(client ExtendedServerBlobAuditingPoliciesClient) (esbap ExtendedServerBlobAuditingPolicy, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - fg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + esbap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { - fg, err = client.CreateOrUpdateResponder(fg.Response.Response) + if esbap.Response.Response, err = future.GetResult(sender); err == nil && esbap.Response.Response.StatusCode != http.StatusNoContent { + esbap, err = client.CreateOrUpdateResponder(esbap.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", esbap.Response.Response, "Failure responding to request") } } return } -// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type FailoverGroupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(FailoverGroupsClient) (autorest.Response, error) +// ExtendedServerBlobAuditingPolicy an extended server blob auditing policy. +type ExtendedServerBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ExtendedServerBlobAuditingPolicyProperties - Resource properties. + *ExtendedServerBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *FailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicy. +func (esbap ExtendedServerBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if esbap.ExtendedServerBlobAuditingPolicyProperties != nil { + objectMap["properties"] = esbap.ExtendedServerBlobAuditingPolicyProperties } - future.FutureAPI = &azFuture - future.Result = future.result - return nil + return json.Marshal(objectMap) } -// result is the default implementation for FailoverGroupsDeleteFuture.Result. -func (future *FailoverGroupsDeleteFuture) result(client FailoverGroupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) +// UnmarshalJSON is the custom unmarshaler for ExtendedServerBlobAuditingPolicy struct. +func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type FailoverGroupsFailoverFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(FailoverGroupsClient) (FailoverGroup, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *FailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for FailoverGroupsFailoverFuture.Result. -func (future *FailoverGroupsFailoverFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - fg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { - fg, err = client.FailoverResponder(fg.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", fg.Response.Response, "Failure responding to request") - } - } - return -} - -// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type FailoverGroupsForceFailoverAllowDataLossFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(FailoverGroupsClient) (FailoverGroup, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *FailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for FailoverGroupsForceFailoverAllowDataLossFuture.Result. -func (future *FailoverGroupsForceFailoverAllowDataLossFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - fg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { - fg, err = client.ForceFailoverAllowDataLossResponder(fg.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", fg.Response.Response, "Failure responding to request") - } - } - return -} - -// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type FailoverGroupsUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(FailoverGroupsClient) (FailoverGroup, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *FailoverGroupsUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for FailoverGroupsUpdateFuture.Result. -func (future *FailoverGroupsUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - fg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { - fg, err = client.UpdateResponder(fg.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") - } - } - return -} - -// FailoverGroupUpdate a failover group update request. -type FailoverGroupUpdate struct { - // FailoverGroupUpdateProperties - Resource properties. - *FailoverGroupUpdateProperties `json:"properties,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for FailoverGroupUpdate. -func (fgu FailoverGroupUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if fgu.FailoverGroupUpdateProperties != nil { - objectMap["properties"] = fgu.FailoverGroupUpdateProperties - } - if fgu.Tags != nil { - objectMap["tags"] = fgu.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for FailoverGroupUpdate struct. -func (fgu *FailoverGroupUpdate) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var failoverGroupUpdateProperties FailoverGroupUpdateProperties - err = json.Unmarshal(*v, &failoverGroupUpdateProperties) - if err != nil { - return err - } - fgu.FailoverGroupUpdateProperties = &failoverGroupUpdateProperties - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - fgu.Tags = tags - } - } - } - - return nil -} - -// FailoverGroupUpdateProperties properties of a failover group update. -type FailoverGroupUpdateProperties struct { - // ReadWriteEndpoint - Read-write endpoint of the failover group instance. - ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` - // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. - ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` - // Databases - List of databases in the failover group. - Databases *[]string `json:"databases,omitempty"` -} - -// FirewallRule a server firewall rule. -type FirewallRule struct { - autorest.Response `json:"-"` - // ServerFirewallRuleProperties - Resource properties. - *ServerFirewallRuleProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for FirewallRule. -func (fr FirewallRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if fr.ServerFirewallRuleProperties != nil { - objectMap["properties"] = fr.ServerFirewallRuleProperties - } - if fr.Name != nil { - objectMap["name"] = fr.Name - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. -func (fr *FirewallRule) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err + return err } for k, v := range m { switch k { case "properties": if v != nil { - var serverFirewallRuleProperties ServerFirewallRuleProperties - err = json.Unmarshal(*v, &serverFirewallRuleProperties) + var extendedServerBlobAuditingPolicyProperties ExtendedServerBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &extendedServerBlobAuditingPolicyProperties) if err != nil { return err } - fr.ServerFirewallRuleProperties = &serverFirewallRuleProperties + esbap.ExtendedServerBlobAuditingPolicyProperties = &extendedServerBlobAuditingPolicyProperties } case "id": if v != nil { @@ -8388,7 +8655,7 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { if err != nil { return err } - fr.ID = &ID + esbap.ID = &ID } case "name": if v != nil { @@ -8397,7 +8664,7 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { if err != nil { return err } - fr.Name = &name + esbap.Name = &name } case "type": if v != nil { @@ -8406,7 +8673,7 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { if err != nil { return err } - fr.Type = &typeVar + esbap.Type = &typeVar } } } @@ -8414,37 +8681,33 @@ func (fr *FirewallRule) UnmarshalJSON(body []byte) error { return nil } -// FirewallRuleList a list of server firewall rules. -type FirewallRuleList struct { - Values *[]FirewallRule `json:"values,omitempty"` -} - -// FirewallRuleListResult the response to a list firewall rules request -type FirewallRuleListResult struct { +// ExtendedServerBlobAuditingPolicyListResult a list of server extended auditing settings. +type ExtendedServerBlobAuditingPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]FirewallRule `json:"value,omitempty"` + Value *[]ExtendedServerBlobAuditingPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for FirewallRuleListResult. -func (frlr FirewallRuleListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicyListResult. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// FirewallRuleListResultIterator provides access to a complete listing of FirewallRule values. -type FirewallRuleListResultIterator struct { +// ExtendedServerBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ExtendedServerBlobAuditingPolicy values. +type ExtendedServerBlobAuditingPolicyListResultIterator struct { i int - page FirewallRuleListResultPage + page ExtendedServerBlobAuditingPolicyListResultPage } // NextWithContext 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 *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -8469,67 +8732,68 @@ func (iter *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *FirewallRuleListResultIterator) Next() error { +func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter FirewallRuleListResultIterator) NotDone() bool { +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) 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 FirewallRuleListResultIterator) Response() FirewallRuleListResult { +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) Response() ExtendedServerBlobAuditingPolicyListResult { 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 FirewallRuleListResultIterator) Value() FirewallRule { +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) Value() ExtendedServerBlobAuditingPolicy { if !iter.page.NotDone() { - return FirewallRule{} + return ExtendedServerBlobAuditingPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the FirewallRuleListResultIterator type. -func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { - return FirewallRuleListResultIterator{page: page} +// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultIterator type. +func NewExtendedServerBlobAuditingPolicyListResultIterator(page ExtendedServerBlobAuditingPolicyListResultPage) ExtendedServerBlobAuditingPolicyListResultIterator { + return ExtendedServerBlobAuditingPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (frlr FirewallRuleListResult) IsEmpty() bool { - return frlr.Value == nil || len(*frlr.Value) == 0 +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) IsEmpty() bool { + return esbaplr.Value == nil || len(*esbaplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (frlr FirewallRuleListResult) hasNextLink() bool { - return frlr.NextLink != nil && len(*frlr.NextLink) != 0 +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) hasNextLink() bool { + return esbaplr.NextLink != nil && len(*esbaplr.NextLink) != 0 } -// firewallRuleListResultPreparer prepares a request to retrieve the next set of results. +// extendedServerBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { - if !frlr.hasNextLink() { +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) extendedServerBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !esbaplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(frlr.NextLink))) + autorest.WithBaseURL(to.String(esbaplr.NextLink))) } -// FirewallRuleListResultPage contains a page of FirewallRule values. -type FirewallRuleListResultPage struct { - fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error) - frlr FirewallRuleListResult +// ExtendedServerBlobAuditingPolicyListResultPage contains a page of ExtendedServerBlobAuditingPolicy +// values. +type ExtendedServerBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error) + esbaplr ExtendedServerBlobAuditingPolicyListResult } // NextWithContext 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 *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ExtendedServerBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -8539,11 +8803,11 @@ func (page *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (er }() } for { - next, err := page.fn(ctx, page.frlr) + next, err := page.fn(ctx, page.esbaplr) if err != nil { return err } - page.frlr = next + page.esbaplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -8554,45 +8818,158 @@ func (page *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (er // 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. // Deprecated: Use NextWithContext() instead. -func (page *FirewallRuleListResultPage) Next() error { +func (page *ExtendedServerBlobAuditingPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page FirewallRuleListResultPage) NotDone() bool { - return !page.frlr.IsEmpty() +func (page ExtendedServerBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.esbaplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page FirewallRuleListResultPage) Response() FirewallRuleListResult { - return page.frlr +func (page ExtendedServerBlobAuditingPolicyListResultPage) Response() ExtendedServerBlobAuditingPolicyListResult { + return page.esbaplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page FirewallRuleListResultPage) Values() []FirewallRule { - if page.frlr.IsEmpty() { +func (page ExtendedServerBlobAuditingPolicyListResultPage) Values() []ExtendedServerBlobAuditingPolicy { + if page.esbaplr.IsEmpty() { return nil } - return *page.frlr.Value + return *page.esbaplr.Value } -// Creates a new instance of the FirewallRuleListResultPage type. -func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { - return FirewallRuleListResultPage{ - fn: getNextPage, - frlr: cur, +// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultPage type. +func NewExtendedServerBlobAuditingPolicyListResultPage(cur ExtendedServerBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error)) ExtendedServerBlobAuditingPolicyListResultPage { + return ExtendedServerBlobAuditingPolicyListResultPage{ + fn: getNextPage, + esbaplr: cur, } } -// GeoBackupPolicy a database geo backup policy. -type GeoBackupPolicy struct { +// ExtendedServerBlobAuditingPolicyProperties properties of an extended server blob auditing policy. +type ExtendedServerBlobAuditingPolicyProperties struct { + // IsDevopsAuditEnabled - Specifies the state of devops audit. If state is Enabled, devops logs will be sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + // + // When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsDevopsAuditEnabled *bool `json:"isDevopsAuditEnabled,omitempty"` + // PredicateExpression - Specifies condition of where clause when creating an audit. + PredicateExpression *string `json:"predicateExpression,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // LEDGER_OPERATION_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // IsManagedIdentityInUse - Specifies whether Managed Identity is used to access blob storage + IsManagedIdentityInUse *bool `json:"isManagedIdentityInUse,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +} + +// FailoverGroup a failover group. +type FailoverGroup struct { autorest.Response `json:"-"` - // GeoBackupPolicyProperties - The properties of the geo backup policy. - *GeoBackupPolicyProperties `json:"properties,omitempty"` - // Kind - READ-ONLY; Kind of geo backup policy. This is metadata used for the Azure portal experience. - Kind *string `json:"kind,omitempty"` - // Location - READ-ONLY; Backup policy location. + // Location - READ-ONLY; Resource location. Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // FailoverGroupProperties - Resource properties. + *FailoverGroupProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -8601,17 +8978,20 @@ type GeoBackupPolicy struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for GeoBackupPolicy. -func (gbp GeoBackupPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for FailoverGroup. +func (fg FailoverGroup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if gbp.GeoBackupPolicyProperties != nil { - objectMap["properties"] = gbp.GeoBackupPolicyProperties + if fg.Tags != nil { + objectMap["tags"] = fg.Tags + } + if fg.FailoverGroupProperties != nil { + objectMap["properties"] = fg.FailoverGroupProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for GeoBackupPolicy struct. -func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for FailoverGroup struct. +func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -8619,32 +8999,32 @@ func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "properties": + case "location": if v != nil { - var geoBackupPolicyProperties GeoBackupPolicyProperties - err = json.Unmarshal(*v, &geoBackupPolicyProperties) + var location string + err = json.Unmarshal(*v, &location) if err != nil { return err } - gbp.GeoBackupPolicyProperties = &geoBackupPolicyProperties + fg.Location = &location } - case "kind": + case "tags": if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) + var tags map[string]*string + err = json.Unmarshal(*v, &tags) if err != nil { return err } - gbp.Kind = &kind + fg.Tags = tags } - case "location": + case "properties": if v != nil { - var location string - err = json.Unmarshal(*v, &location) + var failoverGroupProperties FailoverGroupProperties + err = json.Unmarshal(*v, &failoverGroupProperties) if err != nil { return err } - gbp.Location = &location + fg.FailoverGroupProperties = &failoverGroupProperties } case "id": if v != nil { @@ -8653,7 +9033,7 @@ func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - gbp.ID = &ID + fg.ID = &ID } case "name": if v != nil { @@ -8662,7 +9042,7 @@ func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - gbp.Name = &name + fg.Name = &name } case "type": if v != nil { @@ -8671,7 +9051,7 @@ func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - gbp.Type = &typeVar + fg.Type = &typeVar } } } @@ -8679,76 +9059,32 @@ func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { return nil } -// GeoBackupPolicyListResult the response to a list geo backup policies request. -type GeoBackupPolicyListResult struct { - autorest.Response `json:"-"` - // Value - The list of geo backup policies. - Value *[]GeoBackupPolicy `json:"value,omitempty"` -} - -// GeoBackupPolicyProperties the properties of the geo backup policy. -type GeoBackupPolicyProperties struct { - // State - The state of the geo backup policy. Possible values include: 'GeoBackupPolicyStateDisabled', 'GeoBackupPolicyStateEnabled' - State GeoBackupPolicyState `json:"state,omitempty"` - // StorageType - READ-ONLY; The storage type of the geo backup policy. - StorageType *string `json:"storageType,omitempty"` -} - -// MarshalJSON is the custom marshaler for GeoBackupPolicyProperties. -func (gbpp GeoBackupPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gbpp.State != "" { - objectMap["state"] = gbpp.State - } - return json.Marshal(objectMap) -} - -// ImportExistingDatabaseDefinition contains the information necessary to perform import operation for -// existing database. -type ImportExistingDatabaseDefinition struct { - // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' - StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` - // StorageKey - Storage key. - StorageKey *string `json:"storageKey,omitempty"` - // StorageURI - Storage Uri. - StorageURI *string `json:"storageUri,omitempty"` - // AdministratorLogin - Administrator login name. - AdministratorLogin *string `json:"administratorLogin,omitempty"` - // AdministratorLoginPassword - Administrator login password. - AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` - // AuthenticationType - Authentication type. - AuthenticationType *string `json:"authenticationType,omitempty"` - // NetworkIsolation - Optional resource information to enable network isolation for request. - NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` -} - -// ImportExportExtensionsOperationListResult import export operation extensions list. -type ImportExportExtensionsOperationListResult struct { +// FailoverGroupListResult a list of failover groups. +type FailoverGroupListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ImportExportExtensionsOperationResult `json:"value,omitempty"` + Value *[]FailoverGroup `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationListResult. -func (ieeolr ImportExportExtensionsOperationListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for FailoverGroupListResult. +func (fglr FailoverGroupListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ImportExportExtensionsOperationListResultIterator provides access to a complete listing of -// ImportExportExtensionsOperationResult values. -type ImportExportExtensionsOperationListResultIterator struct { +// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. +type FailoverGroupListResultIterator struct { i int - page ImportExportExtensionsOperationListResultPage + page FailoverGroupListResultPage } // NextWithContext 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 *ImportExportExtensionsOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *FailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportExtensionsOperationListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -8773,68 +9109,67 @@ func (iter *ImportExportExtensionsOperationListResultIterator) NextWithContext(c // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ImportExportExtensionsOperationListResultIterator) Next() error { +func (iter *FailoverGroupListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ImportExportExtensionsOperationListResultIterator) NotDone() bool { +func (iter FailoverGroupListResultIterator) 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 ImportExportExtensionsOperationListResultIterator) Response() ImportExportExtensionsOperationListResult { +func (iter FailoverGroupListResultIterator) Response() FailoverGroupListResult { 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 ImportExportExtensionsOperationListResultIterator) Value() ImportExportExtensionsOperationResult { +func (iter FailoverGroupListResultIterator) Value() FailoverGroup { if !iter.page.NotDone() { - return ImportExportExtensionsOperationResult{} + return FailoverGroup{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ImportExportExtensionsOperationListResultIterator type. -func NewImportExportExtensionsOperationListResultIterator(page ImportExportExtensionsOperationListResultPage) ImportExportExtensionsOperationListResultIterator { - return ImportExportExtensionsOperationListResultIterator{page: page} +// Creates a new instance of the FailoverGroupListResultIterator type. +func NewFailoverGroupListResultIterator(page FailoverGroupListResultPage) FailoverGroupListResultIterator { + return FailoverGroupListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (ieeolr ImportExportExtensionsOperationListResult) IsEmpty() bool { - return ieeolr.Value == nil || len(*ieeolr.Value) == 0 +func (fglr FailoverGroupListResult) IsEmpty() bool { + return fglr.Value == nil || len(*fglr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (ieeolr ImportExportExtensionsOperationListResult) hasNextLink() bool { - return ieeolr.NextLink != nil && len(*ieeolr.NextLink) != 0 +func (fglr FailoverGroupListResult) hasNextLink() bool { + return fglr.NextLink != nil && len(*fglr.NextLink) != 0 } -// importExportExtensionsOperationListResultPreparer prepares a request to retrieve the next set of results. +// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (ieeolr ImportExportExtensionsOperationListResult) importExportExtensionsOperationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ieeolr.hasNextLink() { +func (fglr FailoverGroupListResult) failoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !fglr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(ieeolr.NextLink))) + autorest.WithBaseURL(to.String(fglr.NextLink))) } -// ImportExportExtensionsOperationListResultPage contains a page of ImportExportExtensionsOperationResult -// values. -type ImportExportExtensionsOperationListResultPage struct { - fn func(context.Context, ImportExportExtensionsOperationListResult) (ImportExportExtensionsOperationListResult, error) - ieeolr ImportExportExtensionsOperationListResult +// FailoverGroupListResultPage contains a page of FailoverGroup values. +type FailoverGroupListResultPage struct { + fn func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error) + fglr FailoverGroupListResult } // NextWithContext 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 *ImportExportExtensionsOperationListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportExtensionsOperationListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -8844,11 +9179,11 @@ func (page *ImportExportExtensionsOperationListResultPage) NextWithContext(ctx c }() } for { - next, err := page.fn(ctx, page.ieeolr) + next, err := page.fn(ctx, page.fglr) if err != nil { return err } - page.ieeolr = next + page.fglr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -8859,304 +9194,398 @@ func (page *ImportExportExtensionsOperationListResultPage) NextWithContext(ctx c // 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. // Deprecated: Use NextWithContext() instead. -func (page *ImportExportExtensionsOperationListResultPage) Next() error { +func (page *FailoverGroupListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ImportExportExtensionsOperationListResultPage) NotDone() bool { - return !page.ieeolr.IsEmpty() +func (page FailoverGroupListResultPage) NotDone() bool { + return !page.fglr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ImportExportExtensionsOperationListResultPage) Response() ImportExportExtensionsOperationListResult { - return page.ieeolr +func (page FailoverGroupListResultPage) Response() FailoverGroupListResult { + return page.fglr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ImportExportExtensionsOperationListResultPage) Values() []ImportExportExtensionsOperationResult { - if page.ieeolr.IsEmpty() { +func (page FailoverGroupListResultPage) Values() []FailoverGroup { + if page.fglr.IsEmpty() { return nil } - return *page.ieeolr.Value + return *page.fglr.Value } -// Creates a new instance of the ImportExportExtensionsOperationListResultPage type. -func NewImportExportExtensionsOperationListResultPage(cur ImportExportExtensionsOperationListResult, getNextPage func(context.Context, ImportExportExtensionsOperationListResult) (ImportExportExtensionsOperationListResult, error)) ImportExportExtensionsOperationListResultPage { - return ImportExportExtensionsOperationListResultPage{ - fn: getNextPage, - ieeolr: cur, +// Creates a new instance of the FailoverGroupListResultPage type. +func NewFailoverGroupListResultPage(cur FailoverGroupListResult, getNextPage func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error)) FailoverGroupListResultPage { + return FailoverGroupListResultPage{ + fn: getNextPage, + fglr: cur, } } -// ImportExportExtensionsOperationResult an Extension operation result resource. -type ImportExportExtensionsOperationResult struct { - autorest.Response `json:"-"` - // ImportExportExtensionsOperationResultProperties - Resource properties. - *ImportExportExtensionsOperationResultProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// FailoverGroupProperties properties of a failover group. +type FailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'FailoverGroupReplicationRolePrimary', 'FailoverGroupReplicationRoleSecondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerServers - List of partner server information for the failover group. + PartnerServers *[]PartnerInfo `json:"partnerServers,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` } -// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationResult. -func (ieeor ImportExportExtensionsOperationResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for FailoverGroupProperties. +func (fgp FailoverGroupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ieeor.ImportExportExtensionsOperationResultProperties != nil { - objectMap["properties"] = ieeor.ImportExportExtensionsOperationResultProperties + if fgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = fgp.ReadWriteEndpoint } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ImportExportExtensionsOperationResult struct. -func (ieeor *ImportExportExtensionsOperationResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err + if fgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = fgp.ReadOnlyEndpoint } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var importExportExtensionsOperationResultProperties ImportExportExtensionsOperationResultProperties - err = json.Unmarshal(*v, &importExportExtensionsOperationResultProperties) - if err != nil { - return err - } - ieeor.ImportExportExtensionsOperationResultProperties = &importExportExtensionsOperationResultProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ieeor.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ieeor.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ieeor.Type = &typeVar - } - } + if fgp.PartnerServers != nil { + objectMap["partnerServers"] = fgp.PartnerServers } - - return nil + if fgp.Databases != nil { + objectMap["databases"] = fgp.Databases + } + return json.Marshal(objectMap) } -// ImportExportExtensionsOperationResultProperties contains the operation result properties for -// import/export operation. -type ImportExportExtensionsOperationResultProperties struct { - // RequestID - READ-ONLY; Request Id. - RequestID *uuid.UUID `json:"requestId,omitempty"` - // RequestType - READ-ONLY; Request type. - RequestType *string `json:"requestType,omitempty"` - // LastModifiedTime - READ-ONLY; Last modified time. - LastModifiedTime *string `json:"lastModifiedTime,omitempty"` - // ServerName - READ-ONLY; Server name. - ServerName *string `json:"serverName,omitempty"` - // DatabaseName - READ-ONLY; Database name. - DatabaseName *string `json:"databaseName,omitempty"` - // Status - READ-ONLY; Operation status. - Status *string `json:"status,omitempty"` - // ErrorMessage - READ-ONLY; Error message. - ErrorMessage *string `json:"errorMessage,omitempty"` +// FailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type FailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` } -// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationResultProperties. -func (ieeorp ImportExportExtensionsOperationResultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// FailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type FailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'ReadWriteEndpointFailoverPolicyManual', 'ReadWriteEndpointFailoverPolicyAutomatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` } -// ImportExportOperationResult an ImportExport operation result resource. -type ImportExportOperationResult struct { - autorest.Response `json:"-"` - // ImportExportOperationResultProperties - Resource properties. - *ImportExportOperationResultProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// FailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) } -// MarshalJSON is the custom marshaler for ImportExportOperationResult. -func (ieor ImportExportOperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ieor.ImportExportOperationResultProperties != nil { - objectMap["properties"] = ieor.ImportExportOperationResultProperties +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return json.Marshal(objectMap) + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// UnmarshalJSON is the custom unmarshaler for ImportExportOperationResult struct. -func (ieor *ImportExportOperationResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// result is the default implementation for FailoverGroupsCreateOrUpdateFuture.Result. +func (future *FailoverGroupsCreateOrUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) if err != nil { - return err + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var importExportOperationResultProperties ImportExportOperationResultProperties - err = json.Unmarshal(*v, &importExportOperationResultProperties) - if err != nil { - return err - } - ieor.ImportExportOperationResultProperties = &importExportOperationResultProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ieor.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ieor.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ieor.Type = &typeVar - } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.CreateOrUpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") } } + return +} + +// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (autorest.Response, error) +} +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result return nil } -// ImportExportOperationResultProperties contains the operation result properties for import/export +// result is the default implementation for FailoverGroupsDeleteFuture.Result. +func (future *FailoverGroupsDeleteFuture) result(client FailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running // operation. -type ImportExportOperationResultProperties struct { - // RequestID - READ-ONLY; Request Id. - RequestID *uuid.UUID `json:"requestId,omitempty"` - // RequestType - READ-ONLY; Request type. - RequestType *string `json:"requestType,omitempty"` - // QueuedTime - READ-ONLY; Queued time. - QueuedTime *string `json:"queuedTime,omitempty"` - // LastModifiedTime - READ-ONLY; Last modified time. - LastModifiedTime *string `json:"lastModifiedTime,omitempty"` - // BlobURI - READ-ONLY; Blob Uri. - BlobURI *string `json:"blobUri,omitempty"` - // ServerName - READ-ONLY; Server name. - ServerName *string `json:"serverName,omitempty"` - // DatabaseName - READ-ONLY; Database name. - DatabaseName *string `json:"databaseName,omitempty"` - // Status - READ-ONLY; Operation status. - Status *string `json:"status,omitempty"` - // ErrorMessage - READ-ONLY; Error message. - ErrorMessage *string `json:"errorMessage,omitempty"` - // PrivateEndpointConnections - READ-ONLY; Gets the status of private endpoints associated with this request. - PrivateEndpointConnections *[]PrivateEndpointConnectionRequestStatus `json:"privateEndpointConnections,omitempty"` +type FailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) } -// MarshalJSON is the custom marshaler for ImportExportOperationResultProperties. -func (ieorp ImportExportOperationResultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// ImportNewDatabaseDefinition contains the information necessary to perform import operation for new -// database. -type ImportNewDatabaseDefinition struct { - // DatabaseName - Name of the import database. - DatabaseName *string `json:"databaseName,omitempty"` - // Edition - Edition of the import database. - Edition *string `json:"edition,omitempty"` - // ServiceObjectiveName - Service level objective name of the import database. - ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` - // MaxSizeBytes - Max size in bytes for the import database. - MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` - // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' - StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` - // StorageKey - Storage key. - StorageKey *string `json:"storageKey,omitempty"` - // StorageURI - Storage Uri. - StorageURI *string `json:"storageUri,omitempty"` - // AdministratorLogin - Administrator login name. - AdministratorLogin *string `json:"administratorLogin,omitempty"` - // AdministratorLoginPassword - Administrator login password. - AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` - // AuthenticationType - Authentication type. - AuthenticationType *string `json:"authenticationType,omitempty"` - // NetworkIsolation - Optional resource information to enable network isolation for request. - NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +// result is the default implementation for FailoverGroupsFailoverFuture.Result. +func (future *FailoverGroupsFailoverFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.FailoverResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return } -// InstanceFailoverGroup an instance failover group. -type InstanceFailoverGroup struct { - autorest.Response `json:"-"` - // InstanceFailoverGroupProperties - Resource properties. - *InstanceFailoverGroupProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type FailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) } -// MarshalJSON is the custom marshaler for InstanceFailoverGroup. -func (ifg InstanceFailoverGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ifg.InstanceFailoverGroupProperties != nil { - objectMap["properties"] = ifg.InstanceFailoverGroupProperties +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return json.Marshal(objectMap) + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// UnmarshalJSON is the custom unmarshaler for InstanceFailoverGroup struct. -func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// result is the default implementation for FailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) if err != nil { - return err + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.ForceFailoverAllowDataLossResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsUpdateFuture.Result. +func (future *FailoverGroupsUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.UpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupUpdate a failover group update request. +type FailoverGroupUpdate struct { + // FailoverGroupUpdateProperties - Resource properties. + *FailoverGroupUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupUpdate. +func (fgu FailoverGroupUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgu.FailoverGroupUpdateProperties != nil { + objectMap["properties"] = fgu.FailoverGroupUpdateProperties + } + if fgu.Tags != nil { + objectMap["tags"] = fgu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroupUpdate struct. +func (fgu *FailoverGroupUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err } for k, v := range m { switch k { case "properties": if v != nil { - var instanceFailoverGroupProperties InstanceFailoverGroupProperties - err = json.Unmarshal(*v, &instanceFailoverGroupProperties) + var failoverGroupUpdateProperties FailoverGroupUpdateProperties + err = json.Unmarshal(*v, &failoverGroupUpdateProperties) if err != nil { return err } - ifg.InstanceFailoverGroupProperties = &instanceFailoverGroupProperties + fgu.FailoverGroupUpdateProperties = &failoverGroupUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fgu.Tags = tags + } + } + } + + return nil +} + +// FailoverGroupUpdateProperties properties of a failover group update. +type FailoverGroupUpdateProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// FirewallRule a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // ServerFirewallRuleProperties - Resource properties. + *ServerFirewallRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.ServerFirewallRuleProperties != nil { + objectMap["properties"] = fr.ServerFirewallRuleProperties + } + if fr.Name != nil { + objectMap["name"] = fr.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverFirewallRuleProperties ServerFirewallRuleProperties + err = json.Unmarshal(*v, &serverFirewallRuleProperties) + if err != nil { + return err + } + fr.ServerFirewallRuleProperties = &serverFirewallRuleProperties } case "id": if v != nil { @@ -9165,7 +9594,7 @@ func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { if err != nil { return err } - ifg.ID = &ID + fr.ID = &ID } case "name": if v != nil { @@ -9174,7 +9603,7 @@ func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { if err != nil { return err } - ifg.Name = &name + fr.Name = &name } case "type": if v != nil { @@ -9183,7 +9612,7 @@ func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { if err != nil { return err } - ifg.Type = &typeVar + fr.Type = &typeVar } } } @@ -9191,33 +9620,37 @@ func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { return nil } -// InstanceFailoverGroupListResult a list of instance failover groups. -type InstanceFailoverGroupListResult struct { +// FirewallRuleList a list of server firewall rules. +type FirewallRuleList struct { + Values *[]FirewallRule `json:"values,omitempty"` +} + +// FirewallRuleListResult the response to a list firewall rules request +type FirewallRuleListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]InstanceFailoverGroup `json:"value,omitempty"` + Value *[]FirewallRule `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for InstanceFailoverGroupListResult. -func (ifglr InstanceFailoverGroupListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for FirewallRuleListResult. +func (frlr FirewallRuleListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup -// values. -type InstanceFailoverGroupListResultIterator struct { +// FirewallRuleListResultIterator provides access to a complete listing of FirewallRule values. +type FirewallRuleListResultIterator struct { i int - page InstanceFailoverGroupListResultPage + page FirewallRuleListResultPage } // NextWithContext 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 *InstanceFailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -9242,67 +9675,67 @@ func (iter *InstanceFailoverGroupListResultIterator) NextWithContext(ctx context // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *InstanceFailoverGroupListResultIterator) Next() error { +func (iter *FirewallRuleListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter InstanceFailoverGroupListResultIterator) NotDone() bool { +func (iter FirewallRuleListResultIterator) 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 InstanceFailoverGroupListResultIterator) Response() InstanceFailoverGroupListResult { +func (iter FirewallRuleListResultIterator) Response() FirewallRuleListResult { 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 InstanceFailoverGroupListResultIterator) Value() InstanceFailoverGroup { +func (iter FirewallRuleListResultIterator) Value() FirewallRule { if !iter.page.NotDone() { - return InstanceFailoverGroup{} + return FirewallRule{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the InstanceFailoverGroupListResultIterator type. -func NewInstanceFailoverGroupListResultIterator(page InstanceFailoverGroupListResultPage) InstanceFailoverGroupListResultIterator { - return InstanceFailoverGroupListResultIterator{page: page} +// Creates a new instance of the FirewallRuleListResultIterator type. +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return FirewallRuleListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { - return ifglr.Value == nil || len(*ifglr.Value) == 0 +func (frlr FirewallRuleListResult) IsEmpty() bool { + return frlr.Value == nil || len(*frlr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (ifglr InstanceFailoverGroupListResult) hasNextLink() bool { - return ifglr.NextLink != nil && len(*ifglr.NextLink) != 0 +func (frlr FirewallRuleListResult) hasNextLink() bool { + return frlr.NextLink != nil && len(*frlr.NextLink) != 0 } -// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// firewallRuleListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ifglr.hasNextLink() { +func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !frlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(ifglr.NextLink))) + autorest.WithBaseURL(to.String(frlr.NextLink))) } -// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. -type InstanceFailoverGroupListResultPage struct { - fn func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) - ifglr InstanceFailoverGroupListResult +// FirewallRuleListResultPage contains a page of FirewallRule values. +type FirewallRuleListResultPage struct { + fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error) + frlr FirewallRuleListResult } // NextWithContext 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 *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -9312,11 +9745,11 @@ func (page *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Con }() } for { - next, err := page.fn(ctx, page.ifglr) + next, err := page.fn(ctx, page.frlr) if err != nil { return err } - page.ifglr = next + page.frlr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -9327,261 +9760,346 @@ func (page *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Con // 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. // Deprecated: Use NextWithContext() instead. -func (page *InstanceFailoverGroupListResultPage) Next() error { +func (page *FirewallRuleListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page InstanceFailoverGroupListResultPage) NotDone() bool { - return !page.ifglr.IsEmpty() +func (page FirewallRuleListResultPage) NotDone() bool { + return !page.frlr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page InstanceFailoverGroupListResultPage) Response() InstanceFailoverGroupListResult { - return page.ifglr +func (page FirewallRuleListResultPage) Response() FirewallRuleListResult { + return page.frlr } // Values returns the slice of values for the current page or nil if there are no values. -func (page InstanceFailoverGroupListResultPage) Values() []InstanceFailoverGroup { - if page.ifglr.IsEmpty() { +func (page FirewallRuleListResultPage) Values() []FirewallRule { + if page.frlr.IsEmpty() { return nil } - return *page.ifglr.Value + return *page.frlr.Value } -// Creates a new instance of the InstanceFailoverGroupListResultPage type. -func NewInstanceFailoverGroupListResultPage(cur InstanceFailoverGroupListResult, getNextPage func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error)) InstanceFailoverGroupListResultPage { - return InstanceFailoverGroupListResultPage{ - fn: getNextPage, - ifglr: cur, +// Creates a new instance of the FirewallRuleListResultPage type. +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return FirewallRuleListResultPage{ + fn: getNextPage, + frlr: cur, } } -// InstanceFailoverGroupProperties properties of a instance failover group. -type InstanceFailoverGroupProperties struct { - // ReadWriteEndpoint - Read-write endpoint of the failover group instance. - ReadWriteEndpoint *InstanceFailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` - // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. - ReadOnlyEndpoint *InstanceFailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` - // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'InstanceFailoverGroupReplicationRolePrimary', 'InstanceFailoverGroupReplicationRoleSecondary' - ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` - // ReplicationState - READ-ONLY; Replication state of the failover group instance. - ReplicationState *string `json:"replicationState,omitempty"` - // PartnerRegions - Partner region information for the failover group. - PartnerRegions *[]PartnerRegionInfo `json:"partnerRegions,omitempty"` - // ManagedInstancePairs - List of managed instance pairs in the failover group. - ManagedInstancePairs *[]ManagedInstancePairInfo `json:"managedInstancePairs,omitempty"` +// GeoBackupPolicy a database geo backup policy. +type GeoBackupPolicy struct { + autorest.Response `json:"-"` + // GeoBackupPolicyProperties - The properties of the geo backup policy. + *GeoBackupPolicyProperties `json:"properties,omitempty"` + // Kind - READ-ONLY; Kind of geo backup policy. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Backup policy location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for InstanceFailoverGroupProperties. -func (ifgp InstanceFailoverGroupProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for GeoBackupPolicy. +func (gbp GeoBackupPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ifgp.ReadWriteEndpoint != nil { - objectMap["readWriteEndpoint"] = ifgp.ReadWriteEndpoint - } - if ifgp.ReadOnlyEndpoint != nil { - objectMap["readOnlyEndpoint"] = ifgp.ReadOnlyEndpoint - } - if ifgp.PartnerRegions != nil { - objectMap["partnerRegions"] = ifgp.PartnerRegions - } - if ifgp.ManagedInstancePairs != nil { - objectMap["managedInstancePairs"] = ifgp.ManagedInstancePairs + if gbp.GeoBackupPolicyProperties != nil { + objectMap["properties"] = gbp.GeoBackupPolicyProperties } return json.Marshal(objectMap) } -// InstanceFailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. -type InstanceFailoverGroupReadOnlyEndpoint struct { - // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' - FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` -} +// UnmarshalJSON is the custom unmarshaler for GeoBackupPolicy struct. +func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var geoBackupPolicyProperties GeoBackupPolicyProperties + err = json.Unmarshal(*v, &geoBackupPolicyProperties) + if err != nil { + return err + } + gbp.GeoBackupPolicyProperties = &geoBackupPolicyProperties + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + gbp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gbp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gbp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gbp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gbp.Type = &typeVar + } + } + } -// InstanceFailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. -type InstanceFailoverGroupReadWriteEndpoint struct { - // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'ReadWriteEndpointFailoverPolicyManual', 'ReadWriteEndpointFailoverPolicyAutomatic' - FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` - // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. - FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` + return nil } -// InstanceFailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type InstanceFailoverGroupsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +// GeoBackupPolicyListResult the response to a list geo backup policies request. +type GeoBackupPolicyListResult struct { + autorest.Response `json:"-"` + // Value - The list of geo backup policies. + Value *[]GeoBackupPolicy `json:"value,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstanceFailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// GeoBackupPolicyProperties the properties of the geo backup policy. +type GeoBackupPolicyProperties struct { + // State - The state of the geo backup policy. Possible values include: 'GeoBackupPolicyStateDisabled', 'GeoBackupPolicyStateEnabled' + State GeoBackupPolicyState `json:"state,omitempty"` + // StorageType - READ-ONLY; The storage type of the geo backup policy. + StorageType *string `json:"storageType,omitempty"` } -// result is the default implementation for InstanceFailoverGroupsCreateOrUpdateFuture.Result. -func (future *InstanceFailoverGroupsCreateOrUpdateFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ifg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { - ifg, err = client.CreateOrUpdateResponder(ifg.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", ifg.Response.Response, "Failure responding to request") - } +// MarshalJSON is the custom marshaler for GeoBackupPolicyProperties. +func (gbpp GeoBackupPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbpp.State != "" { + objectMap["state"] = gbpp.State } - return + return json.Marshal(objectMap) } -// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type InstanceFailoverGroupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(InstanceFailoverGroupsClient) (autorest.Response, error) +// ImportExistingDatabaseDefinition contains the information necessary to perform import operation for +// existing database. +type ImportExistingDatabaseDefinition struct { + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstanceFailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// ImportExportExtensionsOperationListResult import export operation extensions list. +type ImportExportExtensionsOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ImportExportExtensionsOperationResult `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// result is the default implementation for InstanceFailoverGroupsDeleteFuture.Result. -func (future *InstanceFailoverGroupsDeleteFuture) result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") - return - } - ar.Response = future.Response() - return +// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationListResult. +func (ieeolr ImportExportExtensionsOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) } -// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type InstanceFailoverGroupsFailoverFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +// ImportExportExtensionsOperationListResultIterator provides access to a complete listing of +// ImportExportExtensionsOperationResult values. +type ImportExportExtensionsOperationListResultIterator struct { + i int + page ImportExportExtensionsOperationListResultPage } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstanceFailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { +// NextWithContext 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 *ImportExportExtensionsOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportExtensionsOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- return err } - future.FutureAPI = &azFuture - future.Result = future.result + iter.i = 0 return nil } -// result is the default implementation for InstanceFailoverGroupsFailoverFuture.Result. -func (future *InstanceFailoverGroupsFailoverFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") - return +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ImportExportExtensionsOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ImportExportExtensionsOperationListResultIterator) 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 ImportExportExtensionsOperationListResultIterator) Response() ImportExportExtensionsOperationListResult { + 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 ImportExportExtensionsOperationListResultIterator) Value() ImportExportExtensionsOperationResult { + if !iter.page.NotDone() { + return ImportExportExtensionsOperationResult{} } - if !done { - ifg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") - return + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ImportExportExtensionsOperationListResultIterator type. +func NewImportExportExtensionsOperationListResultIterator(page ImportExportExtensionsOperationListResultPage) ImportExportExtensionsOperationListResultIterator { + return ImportExportExtensionsOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ieeolr ImportExportExtensionsOperationListResult) IsEmpty() bool { + return ieeolr.Value == nil || len(*ieeolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ieeolr ImportExportExtensionsOperationListResult) hasNextLink() bool { + return ieeolr.NextLink != nil && len(*ieeolr.NextLink) != 0 +} + +// importExportExtensionsOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ieeolr ImportExportExtensionsOperationListResult) importExportExtensionsOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ieeolr.hasNextLink() { + return nil, nil } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { - ifg, err = client.FailoverResponder(ifg.Response.Response) + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ieeolr.NextLink))) +} + +// ImportExportExtensionsOperationListResultPage contains a page of ImportExportExtensionsOperationResult +// values. +type ImportExportExtensionsOperationListResultPage struct { + fn func(context.Context, ImportExportExtensionsOperationListResult) (ImportExportExtensionsOperationListResult, error) + ieeolr ImportExportExtensionsOperationListResult +} + +// NextWithContext 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 *ImportExportExtensionsOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportExtensionsOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ieeolr) if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", ifg.Response.Response, "Failure responding to request") + return err + } + page.ieeolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break } } - return + return nil } -// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ImportExportExtensionsOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ImportExportExtensionsOperationListResultPage) NotDone() bool { + return !page.ieeolr.IsEmpty() } -// result is the default implementation for InstanceFailoverGroupsForceFailoverAllowDataLossFuture.Result. -func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ifg.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") - return +// Response returns the raw server response from the last page request. +func (page ImportExportExtensionsOperationListResultPage) Response() ImportExportExtensionsOperationListResult { + return page.ieeolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ImportExportExtensionsOperationListResultPage) Values() []ImportExportExtensionsOperationResult { + if page.ieeolr.IsEmpty() { + return nil } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { - ifg, err = client.ForceFailoverAllowDataLossResponder(ifg.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", ifg.Response.Response, "Failure responding to request") - } + return *page.ieeolr.Value +} + +// Creates a new instance of the ImportExportExtensionsOperationListResultPage type. +func NewImportExportExtensionsOperationListResultPage(cur ImportExportExtensionsOperationListResult, getNextPage func(context.Context, ImportExportExtensionsOperationListResult) (ImportExportExtensionsOperationListResult, error)) ImportExportExtensionsOperationListResultPage { + return ImportExportExtensionsOperationListResultPage{ + fn: getNextPage, + ieeolr: cur, } - return } -// InstancePool an Azure SQL instance pool. -type InstancePool struct { +// ImportExportExtensionsOperationResult an Extension operation result resource. +type ImportExportExtensionsOperationResult struct { autorest.Response `json:"-"` - // Sku - The name and tier of the SKU. - Sku *Sku `json:"sku,omitempty"` - // InstancePoolProperties - Resource properties. - *InstancePoolProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` + // ImportExportExtensionsOperationResultProperties - Resource properties. + *ImportExportExtensionsOperationResultProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -9590,26 +10108,17 @@ type InstancePool struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for InstancePool. -func (IP InstancePool) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationResult. +func (ieeor ImportExportExtensionsOperationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if IP.Sku != nil { - objectMap["sku"] = IP.Sku - } - if IP.InstancePoolProperties != nil { - objectMap["properties"] = IP.InstancePoolProperties - } - if IP.Location != nil { - objectMap["location"] = IP.Location - } - if IP.Tags != nil { - objectMap["tags"] = IP.Tags + if ieeor.ImportExportExtensionsOperationResultProperties != nil { + objectMap["properties"] = ieeor.ImportExportExtensionsOperationResultProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for InstancePool struct. -func (IP *InstancePool) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ImportExportExtensionsOperationResult struct. +func (ieeor *ImportExportExtensionsOperationResult) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -9617,41 +10126,14 @@ func (IP *InstancePool) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - IP.Sku = &sku - } case "properties": if v != nil { - var instancePoolProperties InstancePoolProperties - err = json.Unmarshal(*v, &instancePoolProperties) - if err != nil { - return err - } - IP.InstancePoolProperties = &instancePoolProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - IP.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) + var importExportExtensionsOperationResultProperties ImportExportExtensionsOperationResultProperties + err = json.Unmarshal(*v, &importExportExtensionsOperationResultProperties) if err != nil { return err } - IP.Tags = tags + ieeor.ImportExportExtensionsOperationResultProperties = &importExportExtensionsOperationResultProperties } case "id": if v != nil { @@ -9660,7 +10142,7 @@ func (IP *InstancePool) UnmarshalJSON(body []byte) error { if err != nil { return err } - IP.ID = &ID + ieeor.ID = &ID } case "name": if v != nil { @@ -9669,7 +10151,7 @@ func (IP *InstancePool) UnmarshalJSON(body []byte) error { if err != nil { return err } - IP.Name = &name + ieeor.Name = &name } case "type": if v != nil { @@ -9678,7 +10160,7 @@ func (IP *InstancePool) UnmarshalJSON(body []byte) error { if err != nil { return err } - IP.Type = &typeVar + ieeor.Type = &typeVar } } } @@ -9686,161 +10168,347 @@ func (IP *InstancePool) UnmarshalJSON(body []byte) error { return nil } -// InstancePoolEditionCapability the instance pool capability -type InstancePoolEditionCapability struct { - // Name - READ-ONLY; The instance pool version name. - Name *string `json:"name,omitempty"` - // SupportedFamilies - READ-ONLY; The supported families. - SupportedFamilies *[]InstancePoolFamilyCapability `json:"supportedFamilies,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` +// ImportExportExtensionsOperationResultProperties contains the operation result properties for +// import/export operation. +type ImportExportExtensionsOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // RequestType - READ-ONLY; Request type. + RequestType *string `json:"requestType,omitempty"` + // LastModifiedTime - READ-ONLY; Last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // ServerName - READ-ONLY; Server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - READ-ONLY; Operation status. + Status *string `json:"status,omitempty"` + // ErrorMessage - READ-ONLY; Error message. + ErrorMessage *string `json:"errorMessage,omitempty"` } -// MarshalJSON is the custom marshaler for InstancePoolEditionCapability. -func (ipec InstancePoolEditionCapability) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationResultProperties. +func (ieeorp ImportExportExtensionsOperationResultProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ipec.Reason != nil { - objectMap["reason"] = ipec.Reason - } return json.Marshal(objectMap) } -// InstancePoolFamilyCapability the instance pool family capability. -type InstancePoolFamilyCapability struct { - // Name - READ-ONLY; Family name. +// ImportExportOperationResult an ImportExport operation result resource. +type ImportExportOperationResult struct { + autorest.Response `json:"-"` + // ImportExportOperationResultProperties - Resource properties. + *ImportExportOperationResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. Name *string `json:"name,omitempty"` - // SupportedLicenseTypes - READ-ONLY; List of supported license types. - SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` - // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. - SupportedVcoresValues *[]InstancePoolVcoresCapability `json:"supportedVcoresValues,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for InstancePoolFamilyCapability. -func (ipfc InstancePoolFamilyCapability) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ImportExportOperationResult. +func (ieor ImportExportOperationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ipfc.Reason != nil { - objectMap["reason"] = ipfc.Reason + if ieor.ImportExportOperationResultProperties != nil { + objectMap["properties"] = ieor.ImportExportOperationResultProperties } return json.Marshal(objectMap) } -// InstancePoolListResult a list of Azure SQL instance pools. -type InstancePoolListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]InstancePool `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for InstancePoolListResult. -func (iplr InstancePoolListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// InstancePoolListResultIterator provides access to a complete listing of InstancePool values. -type InstancePoolListResultIterator struct { - i int - page InstancePoolListResultPage -} - -// NextWithContext 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 *InstancePoolListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) +// UnmarshalJSON is the custom unmarshaler for ImportExportOperationResult struct. +func (ieor *ImportExportOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { - iter.i-- return err } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *InstancePoolListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} + for k, v := range m { + switch k { + case "properties": + if v != nil { + var importExportOperationResultProperties ImportExportOperationResultProperties + err = json.Unmarshal(*v, &importExportOperationResultProperties) + if err != nil { + return err + } + ieor.ImportExportOperationResultProperties = &importExportOperationResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ieor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ieor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ieor.Type = &typeVar + } + } + } -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter InstancePoolListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) + return nil } -// Response returns the raw server response from the last page request. -func (iter InstancePoolListResultIterator) Response() InstancePoolListResult { - return iter.page.Response() +// ImportExportOperationResultProperties contains the operation result properties for import/export +// operation. +type ImportExportOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // RequestType - READ-ONLY; Request type. + RequestType *string `json:"requestType,omitempty"` + // QueuedTime - READ-ONLY; Queued time. + QueuedTime *string `json:"queuedTime,omitempty"` + // LastModifiedTime - READ-ONLY; Last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // BlobURI - READ-ONLY; Blob Uri. + BlobURI *string `json:"blobUri,omitempty"` + // ServerName - READ-ONLY; Server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - READ-ONLY; Operation status. + Status *string `json:"status,omitempty"` + // ErrorMessage - READ-ONLY; Error message. + ErrorMessage *string `json:"errorMessage,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Gets the status of private endpoints associated with this request. + PrivateEndpointConnections *[]PrivateEndpointConnectionRequestStatus `json:"privateEndpointConnections,omitempty"` } -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter InstancePoolListResultIterator) Value() InstancePool { - if !iter.page.NotDone() { - return InstancePool{} - } - return iter.page.Values()[iter.i] +// MarshalJSON is the custom marshaler for ImportExportOperationResultProperties. +func (ieorp ImportExportOperationResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) } -// Creates a new instance of the InstancePoolListResultIterator type. -func NewInstancePoolListResultIterator(page InstancePoolListResultPage) InstancePoolListResultIterator { - return InstancePoolListResultIterator{page: page} +// ImportNewDatabaseDefinition contains the information necessary to perform import operation for new +// database. +type ImportNewDatabaseDefinition struct { + // DatabaseName - Name of the import database. + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - Edition of the import database. + Edition *string `json:"edition,omitempty"` + // ServiceObjectiveName - Service level objective name of the import database. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // MaxSizeBytes - Max size in bytes for the import database. + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` } -// IsEmpty returns true if the ListResult contains no values. -func (iplr InstancePoolListResult) IsEmpty() bool { - return iplr.Value == nil || len(*iplr.Value) == 0 +// InstanceFailoverGroup an instance failover group. +type InstanceFailoverGroup struct { + autorest.Response `json:"-"` + // InstanceFailoverGroupProperties - Resource properties. + *InstanceFailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// hasNextLink returns true if the NextLink is not empty. -func (iplr InstancePoolListResult) hasNextLink() bool { - return iplr.NextLink != nil && len(*iplr.NextLink) != 0 +// MarshalJSON is the custom marshaler for InstanceFailoverGroup. +func (ifg InstanceFailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifg.InstanceFailoverGroupProperties != nil { + objectMap["properties"] = ifg.InstanceFailoverGroupProperties + } + return json.Marshal(objectMap) } -// instancePoolListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (iplr InstancePoolListResult) instancePoolListResultPreparer(ctx context.Context) (*http.Request, error) { - if !iplr.hasNextLink() { - return nil, nil - } +// UnmarshalJSON is the custom unmarshaler for InstanceFailoverGroup struct. +func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var instanceFailoverGroupProperties InstanceFailoverGroupProperties + err = json.Unmarshal(*v, &instanceFailoverGroupProperties) + if err != nil { + return err + } + ifg.InstanceFailoverGroupProperties = &instanceFailoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ifg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ifg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ifg.Type = &typeVar + } + } + } + + return nil +} + +// InstanceFailoverGroupListResult a list of instance failover groups. +type InstanceFailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstanceFailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupListResult. +func (ifglr InstanceFailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup +// values. +type InstanceFailoverGroupListResultIterator struct { + i int + page InstanceFailoverGroupListResultPage +} + +// NextWithContext 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 *InstanceFailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstanceFailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstanceFailoverGroupListResultIterator) 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 InstanceFailoverGroupListResultIterator) Response() InstanceFailoverGroupListResult { + 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 InstanceFailoverGroupListResultIterator) Value() InstanceFailoverGroup { + if !iter.page.NotDone() { + return InstanceFailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstanceFailoverGroupListResultIterator type. +func NewInstanceFailoverGroupListResultIterator(page InstanceFailoverGroupListResultPage) InstanceFailoverGroupListResultIterator { + return InstanceFailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { + return ifglr.Value == nil || len(*ifglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ifglr InstanceFailoverGroupListResult) hasNextLink() bool { + return ifglr.NextLink != nil && len(*ifglr.NextLink) != 0 +} + +// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ifglr.hasNextLink() { + return nil, nil + } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(iplr.NextLink))) + autorest.WithBaseURL(to.String(ifglr.NextLink))) } -// InstancePoolListResultPage contains a page of InstancePool values. -type InstancePoolListResultPage struct { - fn func(context.Context, InstancePoolListResult) (InstancePoolListResult, error) - iplr InstancePoolListResult +// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultPage struct { + fn func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) + ifglr InstanceFailoverGroupListResult } // NextWithContext 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 *InstancePoolListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -9850,11 +10518,11 @@ func (page *InstancePoolListResultPage) NextWithContext(ctx context.Context) (er }() } for { - next, err := page.fn(ctx, page.iplr) + next, err := page.fn(ctx, page.ifglr) if err != nil { return err } - page.iplr = next + page.ifglr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -9865,57 +10533,95 @@ func (page *InstancePoolListResultPage) NextWithContext(ctx context.Context) (er // 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. // Deprecated: Use NextWithContext() instead. -func (page *InstancePoolListResultPage) Next() error { +func (page *InstanceFailoverGroupListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page InstancePoolListResultPage) NotDone() bool { - return !page.iplr.IsEmpty() +func (page InstanceFailoverGroupListResultPage) NotDone() bool { + return !page.ifglr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page InstancePoolListResultPage) Response() InstancePoolListResult { - return page.iplr +func (page InstanceFailoverGroupListResultPage) Response() InstanceFailoverGroupListResult { + return page.ifglr } // Values returns the slice of values for the current page or nil if there are no values. -func (page InstancePoolListResultPage) Values() []InstancePool { - if page.iplr.IsEmpty() { +func (page InstanceFailoverGroupListResultPage) Values() []InstanceFailoverGroup { + if page.ifglr.IsEmpty() { return nil } - return *page.iplr.Value + return *page.ifglr.Value } -// Creates a new instance of the InstancePoolListResultPage type. -func NewInstancePoolListResultPage(cur InstancePoolListResult, getNextPage func(context.Context, InstancePoolListResult) (InstancePoolListResult, error)) InstancePoolListResultPage { - return InstancePoolListResultPage{ - fn: getNextPage, - iplr: cur, +// Creates a new instance of the InstanceFailoverGroupListResultPage type. +func NewInstanceFailoverGroupListResultPage(cur InstanceFailoverGroupListResult, getNextPage func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error)) InstanceFailoverGroupListResultPage { + return InstanceFailoverGroupListResultPage{ + fn: getNextPage, + ifglr: cur, } } -// InstancePoolProperties properties of an instance pool. -type InstancePoolProperties struct { - // SubnetID - Resource ID of the subnet to place this instance pool in. - SubnetID *string `json:"subnetId,omitempty"` - // VCores - Count of vCores belonging to this instance pool. - VCores *int32 `json:"vCores,omitempty"` - // LicenseType - The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and 'BasePrice' (without SQL license price). Possible values include: 'InstancePoolLicenseTypeLicenseIncluded', 'InstancePoolLicenseTypeBasePrice' - LicenseType InstancePoolLicenseType `json:"licenseType,omitempty"` +// InstanceFailoverGroupProperties properties of a instance failover group. +type InstanceFailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *InstanceFailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *InstanceFailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'InstanceFailoverGroupReplicationRolePrimary', 'InstanceFailoverGroupReplicationRoleSecondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerRegions - Partner region information for the failover group. + PartnerRegions *[]PartnerRegionInfo `json:"partnerRegions,omitempty"` + // ManagedInstancePairs - List of managed instance pairs in the failover group. + ManagedInstancePairs *[]ManagedInstancePairInfo `json:"managedInstancePairs,omitempty"` } -// InstancePoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// MarshalJSON is the custom marshaler for InstanceFailoverGroupProperties. +func (ifgp InstanceFailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = ifgp.ReadWriteEndpoint + } + if ifgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = ifgp.ReadOnlyEndpoint + } + if ifgp.PartnerRegions != nil { + objectMap["partnerRegions"] = ifgp.PartnerRegions + } + if ifgp.ManagedInstancePairs != nil { + objectMap["managedInstancePairs"] = ifgp.ManagedInstancePairs + } + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type InstanceFailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// InstanceFailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type InstanceFailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'ReadWriteEndpointFailoverPolicyManual', 'ReadWriteEndpointFailoverPolicyAutomatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// InstanceFailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a // long-running operation. -type InstancePoolsCreateOrUpdateFuture struct { +type InstanceFailoverGroupsCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(InstancePoolsClient) (InstancePool, error) + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstancePoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -9925,40 +10631,40 @@ func (future *InstancePoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) erro return nil } -// result is the default implementation for InstancePoolsCreateOrUpdateFuture.Result. -func (future *InstancePoolsCreateOrUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { +// result is the default implementation for InstanceFailoverGroupsCreateOrUpdateFuture.Result. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - IP.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsCreateOrUpdateFuture") + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { - IP, err = client.CreateOrUpdateResponder(IP.Response.Response) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.CreateOrUpdateResponder(ifg.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", ifg.Response.Response, "Failure responding to request") } } return } -// InstancePoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type InstancePoolsDeleteFuture struct { +// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsDeleteFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(InstancePoolsClient) (autorest.Response, error) + Result func(InstanceFailoverGroupsClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstancePoolsDeleteFuture) UnmarshalJSON(body []byte) error { +func (future *InstanceFailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -9968,34 +10674,34 @@ func (future *InstancePoolsDeleteFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for InstancePoolsDeleteFuture.Result. -func (future *InstancePoolsDeleteFuture) result(client InstancePoolsClient) (ar autorest.Response, err error) { +// result is the default implementation for InstanceFailoverGroupsDeleteFuture.Result. +func (future *InstanceFailoverGroupsDeleteFuture) result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstancePoolsDeleteFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsDeleteFuture") + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") return } ar.Response = future.Response() return } -// InstancePoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type InstancePoolsUpdateFuture struct { +// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsFailoverFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(InstancePoolsClient) (InstancePool, error) + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *InstancePoolsUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *InstanceFailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -10005,147 +10711,79 @@ func (future *InstancePoolsUpdateFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for InstancePoolsUpdateFuture.Result. -func (future *InstancePoolsUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { +// result is the default implementation for InstanceFailoverGroupsFailoverFuture.Result. +func (future *InstanceFailoverGroupsFailoverFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - IP.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsUpdateFuture") + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { - IP, err = client.UpdateResponder(IP.Response.Response) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.FailoverResponder(ifg.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", ifg.Response.Response, "Failure responding to request") } } return } -// InstancePoolUpdate an update to an Instance pool. -type InstancePoolUpdate struct { - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for InstancePoolUpdate. -func (ipu InstancePoolUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ipu.Tags != nil { - objectMap["tags"] = ipu.Tags - } - return json.Marshal(objectMap) -} - -// InstancePoolVcoresCapability the managed instance virtual cores capability. -type InstancePoolVcoresCapability struct { - // Name - READ-ONLY; The virtual cores identifier. - Name *string `json:"name,omitempty"` - // Value - READ-ONLY; The virtual cores value. - Value *int32 `json:"value,omitempty"` - // StorageLimit - READ-ONLY; Storage limit. - StorageLimit *MaxSizeCapability `json:"storageLimit,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for InstancePoolVcoresCapability. -func (ipvc InstancePoolVcoresCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ipvc.Reason != nil { - objectMap["reason"] = ipvc.Reason - } - return json.Marshal(objectMap) -} - -// Job a job. -type Job struct { - autorest.Response `json:"-"` - // JobProperties - Resource properties. - *JobProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) } -// MarshalJSON is the custom marshaler for Job. -func (j Job) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if j.JobProperties != nil { - objectMap["properties"] = j.JobProperties +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return json.Marshal(objectMap) + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// 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) +// result is the default implementation for InstanceFailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) if err != nil { - return err + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var jobProperties JobProperties - err = json.Unmarshal(*v, &jobProperties) - if err != nil { - return err - } - j.JobProperties = &jobProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - j.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - j.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - j.Type = &typeVar - } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.ForceFailoverAllowDataLossResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", ifg.Response.Response, "Failure responding to request") } } - - return nil + return } -// JobAgent an Azure SQL job agent. -type JobAgent struct { +// InstancePool an Azure SQL instance pool. +type InstancePool struct { autorest.Response `json:"-"` // Sku - The name and tier of the SKU. Sku *Sku `json:"sku,omitempty"` - // JobAgentProperties - Resource properties. - *JobAgentProperties `json:"properties,omitempty"` + // InstancePoolProperties - Resource properties. + *InstancePoolProperties `json:"properties,omitempty"` // Location - Resource location. Location *string `json:"location,omitempty"` // Tags - Resource tags. @@ -10158,26 +10796,26 @@ type JobAgent struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for JobAgent. -func (ja JobAgent) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for InstancePool. +func (IP InstancePool) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ja.Sku != nil { - objectMap["sku"] = ja.Sku + if IP.Sku != nil { + objectMap["sku"] = IP.Sku } - if ja.JobAgentProperties != nil { - objectMap["properties"] = ja.JobAgentProperties + if IP.InstancePoolProperties != nil { + objectMap["properties"] = IP.InstancePoolProperties } - if ja.Location != nil { - objectMap["location"] = ja.Location + if IP.Location != nil { + objectMap["location"] = IP.Location } - if ja.Tags != nil { - objectMap["tags"] = ja.Tags + if IP.Tags != nil { + objectMap["tags"] = IP.Tags } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for JobAgent struct. -func (ja *JobAgent) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for InstancePool struct. +func (IP *InstancePool) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -10192,16 +10830,16 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { if err != nil { return err } - ja.Sku = &sku + IP.Sku = &sku } case "properties": if v != nil { - var jobAgentProperties JobAgentProperties - err = json.Unmarshal(*v, &jobAgentProperties) + var instancePoolProperties InstancePoolProperties + err = json.Unmarshal(*v, &instancePoolProperties) if err != nil { return err } - ja.JobAgentProperties = &jobAgentProperties + IP.InstancePoolProperties = &instancePoolProperties } case "location": if v != nil { @@ -10210,7 +10848,7 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { if err != nil { return err } - ja.Location = &location + IP.Location = &location } case "tags": if v != nil { @@ -10219,7 +10857,7 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { if err != nil { return err } - ja.Tags = tags + IP.Tags = tags } case "id": if v != nil { @@ -10228,7 +10866,7 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { if err != nil { return err } - ja.ID = &ID + IP.ID = &ID } case "name": if v != nil { @@ -10237,7 +10875,7 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { if err != nil { return err } - ja.Name = &name + IP.Name = &name } case "type": if v != nil { @@ -10246,7 +10884,7 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { if err != nil { return err } - ja.Type = &typeVar + IP.Type = &typeVar } } } @@ -10254,32 +10892,76 @@ func (ja *JobAgent) UnmarshalJSON(body []byte) error { return nil } -// JobAgentListResult a list of Azure SQL job agents. -type JobAgentListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]JobAgent `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` +// InstancePoolEditionCapability the instance pool capability +type InstancePoolEditionCapability struct { + // Name - READ-ONLY; The instance pool version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]InstancePoolFamilyCapability `json:"supportedFamilies,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` } -// MarshalJSON is the custom marshaler for JobAgentListResult. -func (jalr JobAgentListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for InstancePoolEditionCapability. +func (ipec InstancePoolEditionCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if ipec.Reason != nil { + objectMap["reason"] = ipec.Reason + } return json.Marshal(objectMap) } -// JobAgentListResultIterator provides access to a complete listing of JobAgent values. -type JobAgentListResultIterator struct { +// InstancePoolFamilyCapability the instance pool family capability. +type InstancePoolFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]InstancePoolVcoresCapability `json:"supportedVcoresValues,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolFamilyCapability. +func (ipfc InstancePoolFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipfc.Reason != nil { + objectMap["reason"] = ipfc.Reason + } + return json.Marshal(objectMap) +} + +// InstancePoolListResult a list of Azure SQL instance pools. +type InstancePoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstancePool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolListResult. +func (iplr InstancePoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstancePoolListResultIterator provides access to a complete listing of InstancePool values. +type InstancePoolListResultIterator struct { i int - page JobAgentListResultPage + page InstancePoolListResultPage } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (iter *InstancePoolListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -10304,67 +10986,67 @@ func (iter *JobAgentListResultIterator) NextWithContext(ctx context.Context) (er // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobAgentListResultIterator) Next() error { +func (iter *InstancePoolListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobAgentListResultIterator) NotDone() bool { +func (iter InstancePoolListResultIterator) 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 { +func (iter InstancePoolListResultIterator) Response() InstancePoolListResult { 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 { +func (iter InstancePoolListResultIterator) Value() InstancePool { if !iter.page.NotDone() { - return JobAgent{} + return InstancePool{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobAgentListResultIterator type. -func NewJobAgentListResultIterator(page JobAgentListResultPage) JobAgentListResultIterator { - return JobAgentListResultIterator{page: page} +// Creates a new instance of the InstancePoolListResultIterator type. +func NewInstancePoolListResultIterator(page InstancePoolListResultPage) InstancePoolListResultIterator { + return InstancePoolListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jalr JobAgentListResult) IsEmpty() bool { - return jalr.Value == nil || len(*jalr.Value) == 0 +func (iplr InstancePoolListResult) IsEmpty() bool { + return iplr.Value == nil || len(*iplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jalr JobAgentListResult) hasNextLink() bool { - return jalr.NextLink != nil && len(*jalr.NextLink) != 0 +func (iplr InstancePoolListResult) hasNextLink() bool { + return iplr.NextLink != nil && len(*iplr.NextLink) != 0 } -// jobAgentListResultPreparer prepares a request to retrieve the next set of results. +// instancePoolListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jalr JobAgentListResult) jobAgentListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jalr.hasNextLink() { +func (iplr InstancePoolListResult) instancePoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !iplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jalr.NextLink))) + autorest.WithBaseURL(to.String(iplr.NextLink))) } -// JobAgentListResultPage contains a page of JobAgent values. -type JobAgentListResultPage struct { - fn func(context.Context, JobAgentListResult) (JobAgentListResult, error) - jalr JobAgentListResult +// InstancePoolListResultPage contains a page of InstancePool values. +type InstancePoolListResultPage struct { + fn func(context.Context, InstancePoolListResult) (InstancePoolListResult, error) + iplr InstancePoolListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *InstancePoolListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -10374,11 +11056,11 @@ func (page *JobAgentListResultPage) NextWithContext(ctx context.Context) (err er }() } for { - next, err := page.fn(ctx, page.jalr) + next, err := page.fn(ctx, page.iplr) if err != nil { return err } - page.jalr = next + page.iplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -10389,64 +11071,57 @@ func (page *JobAgentListResultPage) NextWithContext(ctx context.Context) (err er // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobAgentListResultPage) Next() error { +func (page *InstancePoolListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobAgentListResultPage) NotDone() bool { - return !page.jalr.IsEmpty() +func (page InstancePoolListResultPage) NotDone() bool { + return !page.iplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobAgentListResultPage) Response() JobAgentListResult { - return page.jalr +func (page InstancePoolListResultPage) Response() InstancePoolListResult { + return page.iplr } // 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() { +func (page InstancePoolListResultPage) Values() []InstancePool { + if page.iplr.IsEmpty() { return nil } - return *page.jalr.Value + return *page.iplr.Value } -// Creates a new instance of the JobAgentListResultPage type. -func NewJobAgentListResultPage(cur JobAgentListResult, getNextPage func(context.Context, JobAgentListResult) (JobAgentListResult, error)) JobAgentListResultPage { - return JobAgentListResultPage{ +// Creates a new instance of the InstancePoolListResultPage type. +func NewInstancePoolListResultPage(cur InstancePoolListResult, getNextPage func(context.Context, InstancePoolListResult) (InstancePoolListResult, error)) InstancePoolListResultPage { + return InstancePoolListResultPage{ fn: getNextPage, - jalr: cur, + iplr: cur, } } -// 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"` - // State - READ-ONLY; The state of the job agent. Possible values include: 'JobAgentStateCreating', 'JobAgentStateReady', 'JobAgentStateUpdating', 'JobAgentStateDeleting', 'JobAgentStateDisabled' - State JobAgentState `json:"state,omitempty"` -} - -// MarshalJSON is the custom marshaler for JobAgentProperties. -func (jap JobAgentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if jap.DatabaseID != nil { - objectMap["databaseId"] = jap.DatabaseID - } - return json.Marshal(objectMap) +// InstancePoolProperties properties of an instance pool. +type InstancePoolProperties struct { + // SubnetID - Resource ID of the subnet to place this instance pool in. + SubnetID *string `json:"subnetId,omitempty"` + // VCores - Count of vCores belonging to this instance pool. + VCores *int32 `json:"vCores,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and 'BasePrice' (without SQL license price). Possible values include: 'InstancePoolLicenseTypeLicenseIncluded', 'InstancePoolLicenseTypeBasePrice' + LicenseType InstancePoolLicenseType `json:"licenseType,omitempty"` } -// JobAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type JobAgentsCreateOrUpdateFuture struct { +// InstancePoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstancePoolsCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(JobAgentsClient) (JobAgent, error) + Result func(InstancePoolsClient) (InstancePool, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *JobAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *InstancePoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -10456,40 +11131,40 @@ func (future *JobAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for JobAgentsCreateOrUpdateFuture.Result. -func (future *JobAgentsCreateOrUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { +// result is the default implementation for InstancePoolsCreateOrUpdateFuture.Result. +func (future *InstancePoolsCreateOrUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - ja.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.JobAgentsCreateOrUpdateFuture") + IP.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { - ja, err = client.CreateOrUpdateResponder(ja.Response.Response) + if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { + IP, err = client.CreateOrUpdateResponder(IP.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") } } return } -// JobAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// InstancePoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running // operation. -type JobAgentsDeleteFuture struct { +type InstancePoolsDeleteFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(JobAgentsClient) (autorest.Response, error) + Result func(InstancePoolsClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *JobAgentsDeleteFuture) UnmarshalJSON(body []byte) error { +func (future *InstancePoolsDeleteFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -10499,34 +11174,34 @@ func (future *JobAgentsDeleteFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for JobAgentsDeleteFuture.Result. -func (future *JobAgentsDeleteFuture) result(client JobAgentsClient) (ar autorest.Response, err error) { +// result is the default implementation for InstancePoolsDeleteFuture.Result. +func (future *InstancePoolsDeleteFuture) result(client InstancePoolsClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.InstancePoolsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.JobAgentsDeleteFuture") + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsDeleteFuture") return } ar.Response = future.Response() return } -// JobAgentsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// InstancePoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. -type JobAgentsUpdateFuture struct { +type InstancePoolsUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(JobAgentsClient) (JobAgent, error) + Result func(InstancePoolsClient) (InstancePool, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *JobAgentsUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *InstancePoolsUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -10536,68 +11211,94 @@ func (future *JobAgentsUpdateFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for JobAgentsUpdateFuture.Result. -func (future *JobAgentsUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { +// result is the default implementation for InstancePoolsUpdateFuture.Result. +func (future *InstancePoolsUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - ja.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.JobAgentsUpdateFuture") + IP.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { - ja, err = client.UpdateResponder(ja.Response.Response) + if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { + IP, err = client.UpdateResponder(IP.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") } } return } -// JobAgentUpdate an update to an Azure SQL job agent. -type JobAgentUpdate struct { +// InstancePoolUpdate an update to an Instance pool. +type InstancePoolUpdate struct { // Tags - Resource tags. Tags map[string]*string `json:"tags"` } -// MarshalJSON is the custom marshaler for JobAgentUpdate. -func (jau JobAgentUpdate) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for InstancePoolUpdate. +func (ipu InstancePoolUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if jau.Tags != nil { - objectMap["tags"] = jau.Tags + if ipu.Tags != nil { + objectMap["tags"] = ipu.Tags } return json.Marshal(objectMap) } -// JobCredential a stored credential that can be used by a job to connect to target databases. -type JobCredential struct { - autorest.Response `json:"-"` - // JobCredentialProperties - Resource properties. - *JobCredentialProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. +// InstancePoolVcoresCapability the managed instance virtual cores capability. +type InstancePoolVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // StorageLimit - READ-ONLY; Storage limit. + StorageLimit *MaxSizeCapability `json:"storageLimit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` } -// MarshalJSON is the custom marshaler for JobCredential. -func (jc JobCredential) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for InstancePoolVcoresCapability. +func (ipvc InstancePoolVcoresCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if jc.JobCredentialProperties != nil { - objectMap["properties"] = jc.JobCredentialProperties + if ipvc.Reason != nil { + objectMap["reason"] = ipvc.Reason } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for JobCredential struct. -func (jc *JobCredential) UnmarshalJSON(body []byte) error { +// IPv6FirewallRule an IPv6 server firewall rule. +type IPv6FirewallRule struct { + autorest.Response `json:"-"` + // IPv6ServerFirewallRuleProperties - Resource properties. + *IPv6ServerFirewallRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IPv6FirewallRule. +func (ip6fr IPv6FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ip6fr.IPv6ServerFirewallRuleProperties != nil { + objectMap["properties"] = ip6fr.IPv6ServerFirewallRuleProperties + } + if ip6fr.Name != nil { + objectMap["name"] = ip6fr.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IPv6FirewallRule struct. +func (ip6fr *IPv6FirewallRule) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -10607,12 +11308,12 @@ func (jc *JobCredential) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var jobCredentialProperties JobCredentialProperties - err = json.Unmarshal(*v, &jobCredentialProperties) + var iPv6ServerFirewallRuleProperties IPv6ServerFirewallRuleProperties + err = json.Unmarshal(*v, &iPv6ServerFirewallRuleProperties) if err != nil { return err } - jc.JobCredentialProperties = &jobCredentialProperties + ip6fr.IPv6ServerFirewallRuleProperties = &iPv6ServerFirewallRuleProperties } case "id": if v != nil { @@ -10621,7 +11322,7 @@ func (jc *JobCredential) UnmarshalJSON(body []byte) error { if err != nil { return err } - jc.ID = &ID + ip6fr.ID = &ID } case "name": if v != nil { @@ -10630,7 +11331,7 @@ func (jc *JobCredential) UnmarshalJSON(body []byte) error { if err != nil { return err } - jc.Name = &name + ip6fr.Name = &name } case "type": if v != nil { @@ -10639,7 +11340,7 @@ func (jc *JobCredential) UnmarshalJSON(body []byte) error { if err != nil { return err } - jc.Type = &typeVar + ip6fr.Type = &typeVar } } } @@ -10647,32 +11348,32 @@ func (jc *JobCredential) UnmarshalJSON(body []byte) error { return nil } -// JobCredentialListResult a list of job credentials. -type JobCredentialListResult struct { +// IPv6FirewallRuleListResult the response to a list IPv6 firewall rules request +type IPv6FirewallRuleListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]JobCredential `json:"value,omitempty"` + Value *[]IPv6FirewallRule `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for JobCredentialListResult. -func (jclr JobCredentialListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for IPv6FirewallRuleListResult. +func (ip6frlr IPv6FirewallRuleListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// JobCredentialListResultIterator provides access to a complete listing of JobCredential values. -type JobCredentialListResultIterator struct { +// IPv6FirewallRuleListResultIterator provides access to a complete listing of IPv6FirewallRule values. +type IPv6FirewallRuleListResultIterator struct { i int - page JobCredentialListResultPage + page IPv6FirewallRuleListResultPage } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (iter *IPv6FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRuleListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -10697,67 +11398,67 @@ func (iter *JobCredentialListResultIterator) NextWithContext(ctx context.Context // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobCredentialListResultIterator) Next() error { +func (iter *IPv6FirewallRuleListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobCredentialListResultIterator) NotDone() bool { +func (iter IPv6FirewallRuleListResultIterator) 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 { +func (iter IPv6FirewallRuleListResultIterator) Response() IPv6FirewallRuleListResult { 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 { +func (iter IPv6FirewallRuleListResultIterator) Value() IPv6FirewallRule { if !iter.page.NotDone() { - return JobCredential{} + return IPv6FirewallRule{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobCredentialListResultIterator type. -func NewJobCredentialListResultIterator(page JobCredentialListResultPage) JobCredentialListResultIterator { - return JobCredentialListResultIterator{page: page} +// Creates a new instance of the IPv6FirewallRuleListResultIterator type. +func NewIPv6FirewallRuleListResultIterator(page IPv6FirewallRuleListResultPage) IPv6FirewallRuleListResultIterator { + return IPv6FirewallRuleListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jclr JobCredentialListResult) IsEmpty() bool { - return jclr.Value == nil || len(*jclr.Value) == 0 +func (ip6frlr IPv6FirewallRuleListResult) IsEmpty() bool { + return ip6frlr.Value == nil || len(*ip6frlr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jclr JobCredentialListResult) hasNextLink() bool { - return jclr.NextLink != nil && len(*jclr.NextLink) != 0 +func (ip6frlr IPv6FirewallRuleListResult) hasNextLink() bool { + return ip6frlr.NextLink != nil && len(*ip6frlr.NextLink) != 0 } -// jobCredentialListResultPreparer prepares a request to retrieve the next set of results. +// iPv6FirewallRuleListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jclr JobCredentialListResult) jobCredentialListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jclr.hasNextLink() { +func (ip6frlr IPv6FirewallRuleListResult) iPv6FirewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ip6frlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jclr.NextLink))) + autorest.WithBaseURL(to.String(ip6frlr.NextLink))) } -// JobCredentialListResultPage contains a page of JobCredential values. -type JobCredentialListResultPage struct { - fn func(context.Context, JobCredentialListResult) (JobCredentialListResult, error) - jclr JobCredentialListResult +// IPv6FirewallRuleListResultPage contains a page of IPv6FirewallRule values. +type IPv6FirewallRuleListResultPage struct { + fn func(context.Context, IPv6FirewallRuleListResult) (IPv6FirewallRuleListResult, error) + ip6frlr IPv6FirewallRuleListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *IPv6FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/IPv6FirewallRuleListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -10767,11 +11468,11 @@ func (page *JobCredentialListResultPage) NextWithContext(ctx context.Context) (e }() } for { - next, err := page.fn(ctx, page.jclr) + next, err := page.fn(ctx, page.ip6frlr) if err != nil { return err } - page.jclr = next + page.ip6frlr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -10782,49 +11483,49 @@ func (page *JobCredentialListResultPage) NextWithContext(ctx context.Context) (e // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobCredentialListResultPage) Next() error { +func (page *IPv6FirewallRuleListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobCredentialListResultPage) NotDone() bool { - return !page.jclr.IsEmpty() +func (page IPv6FirewallRuleListResultPage) NotDone() bool { + return !page.ip6frlr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobCredentialListResultPage) Response() JobCredentialListResult { - return page.jclr +func (page IPv6FirewallRuleListResultPage) Response() IPv6FirewallRuleListResult { + return page.ip6frlr } // 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() { +func (page IPv6FirewallRuleListResultPage) Values() []IPv6FirewallRule { + if page.ip6frlr.IsEmpty() { return nil } - return *page.jclr.Value + return *page.ip6frlr.Value } -// Creates a new instance of the JobCredentialListResultPage type. -func NewJobCredentialListResultPage(cur JobCredentialListResult, getNextPage func(context.Context, JobCredentialListResult) (JobCredentialListResult, error)) JobCredentialListResultPage { - return JobCredentialListResultPage{ - fn: getNextPage, - jclr: cur, +// Creates a new instance of the IPv6FirewallRuleListResultPage type. +func NewIPv6FirewallRuleListResultPage(cur IPv6FirewallRuleListResult, getNextPage func(context.Context, IPv6FirewallRuleListResult) (IPv6FirewallRuleListResult, error)) IPv6FirewallRuleListResultPage { + return IPv6FirewallRuleListResultPage{ + fn: getNextPage, + ip6frlr: cur, } } -// 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"` +// IPv6ServerFirewallRuleProperties the properties of an IPv6 server firewall rule. +type IPv6ServerFirewallRuleProperties struct { + // StartIPv6Address - The start IP address of the firewall rule. Must be IPv6 format. + StartIPv6Address *string `json:"startIPv6Address,omitempty"` + // EndIPv6Address - The end IP address of the firewall rule. Must be IPv6 format. Must be greater than or equal to startIpAddress. + EndIPv6Address *string `json:"endIPv6Address,omitempty"` } -// JobExecution an execution of a job -type JobExecution struct { +// Job a job. +type Job struct { autorest.Response `json:"-"` - // JobExecutionProperties - Resource properties. - *JobExecutionProperties `json:"properties,omitempty"` + // JobProperties - Resource properties. + *JobProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -10833,17 +11534,17 @@ type JobExecution struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for JobExecution. -func (je JobExecution) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for Job. +func (j Job) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if je.JobExecutionProperties != nil { - objectMap["properties"] = je.JobExecutionProperties + if j.JobProperties != nil { + objectMap["properties"] = j.JobProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for JobExecution struct. -func (je *JobExecution) UnmarshalJSON(body []byte) error { +// 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 { @@ -10853,12 +11554,12 @@ func (je *JobExecution) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var jobExecutionProperties JobExecutionProperties - err = json.Unmarshal(*v, &jobExecutionProperties) + var jobProperties JobProperties + err = json.Unmarshal(*v, &jobProperties) if err != nil { return err } - je.JobExecutionProperties = &jobExecutionProperties + j.JobProperties = &jobProperties } case "id": if v != nil { @@ -10867,7 +11568,7 @@ func (je *JobExecution) UnmarshalJSON(body []byte) error { if err != nil { return err } - je.ID = &ID + j.ID = &ID } case "name": if v != nil { @@ -10876,7 +11577,7 @@ func (je *JobExecution) UnmarshalJSON(body []byte) error { if err != nil { return err } - je.Name = &name + j.Name = &name } case "type": if v != nil { @@ -10885,7 +11586,7 @@ func (je *JobExecution) UnmarshalJSON(body []byte) error { if err != nil { return err } - je.Type = &typeVar + j.Type = &typeVar } } } @@ -10893,32 +11594,147 @@ func (je *JobExecution) UnmarshalJSON(body []byte) error { return nil } -// JobExecutionListResult a list of job executions. -type JobExecutionListResult struct { +// JobAgent an Azure SQL job agent. +type JobAgent struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // JobAgentProperties - Resource properties. + *JobAgentProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgent. +func (ja JobAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ja.Sku != nil { + objectMap["sku"] = ja.Sku + } + if ja.JobAgentProperties != nil { + objectMap["properties"] = ja.JobAgentProperties + } + if ja.Location != nil { + objectMap["location"] = ja.Location + } + if ja.Tags != nil { + objectMap["tags"] = ja.Tags + } + return json.Marshal(objectMap) +} + +// 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 + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ja.Sku = &sku + } + case "properties": + if v != nil { + var jobAgentProperties JobAgentProperties + err = json.Unmarshal(*v, &jobAgentProperties) + if err != nil { + return err + } + ja.JobAgentProperties = &jobAgentProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ja.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ja.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ja.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ja.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &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 - READ-ONLY; Array of results. - Value *[]JobExecution `json:"value,omitempty"` + Value *[]JobAgent `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for JobExecutionListResult. -func (jelr JobExecutionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobAgentListResult. +func (jalr JobAgentListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// JobExecutionListResultIterator provides access to a complete listing of JobExecution values. -type JobExecutionListResultIterator struct { +// JobAgentListResultIterator provides access to a complete listing of JobAgent values. +type JobAgentListResultIterator struct { i int - page JobExecutionListResultPage + page JobAgentListResultPage } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (iter *JobAgentListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -10943,67 +11759,67 @@ func (iter *JobExecutionListResultIterator) NextWithContext(ctx context.Context) // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobExecutionListResultIterator) Next() error { +func (iter *JobAgentListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobExecutionListResultIterator) NotDone() bool { +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 JobExecutionListResultIterator) Response() JobExecutionListResult { +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 JobExecutionListResultIterator) Value() JobExecution { +func (iter JobAgentListResultIterator) Value() JobAgent { if !iter.page.NotDone() { - return JobExecution{} + return JobAgent{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobExecutionListResultIterator type. -func NewJobExecutionListResultIterator(page JobExecutionListResultPage) JobExecutionListResultIterator { - return JobExecutionListResultIterator{page: page} +// Creates a new instance of the JobAgentListResultIterator type. +func NewJobAgentListResultIterator(page JobAgentListResultPage) JobAgentListResultIterator { + return JobAgentListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jelr JobExecutionListResult) IsEmpty() bool { - return jelr.Value == nil || len(*jelr.Value) == 0 +func (jalr JobAgentListResult) IsEmpty() bool { + return jalr.Value == nil || len(*jalr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jelr JobExecutionListResult) hasNextLink() bool { - return jelr.NextLink != nil && len(*jelr.NextLink) != 0 +func (jalr JobAgentListResult) hasNextLink() bool { + return jalr.NextLink != nil && len(*jalr.NextLink) != 0 } -// jobExecutionListResultPreparer prepares a request to retrieve the next set of results. +// jobAgentListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jelr JobExecutionListResult) jobExecutionListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jelr.hasNextLink() { +func (jalr JobAgentListResult) jobAgentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jalr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jelr.NextLink))) + autorest.WithBaseURL(to.String(jalr.NextLink))) } -// JobExecutionListResultPage contains a page of JobExecution values. -type JobExecutionListResultPage struct { - fn func(context.Context, JobExecutionListResult) (JobExecutionListResult, error) - jelr JobExecutionListResult +// JobAgentListResultPage contains a page of JobAgent values. +type JobAgentListResultPage struct { + fn func(context.Context, JobAgentListResult) (JobAgentListResult, error) + jalr JobAgentListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *JobAgentListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -11013,11 +11829,11 @@ func (page *JobExecutionListResultPage) NextWithContext(ctx context.Context) (er }() } for { - next, err := page.fn(ctx, page.jelr) + next, err := page.fn(ctx, page.jalr) if err != nil { return err } - page.jelr = next + page.jalr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -11028,86 +11844,64 @@ func (page *JobExecutionListResultPage) NextWithContext(ctx context.Context) (er // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobExecutionListResultPage) Next() error { +func (page *JobAgentListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobExecutionListResultPage) NotDone() bool { - return !page.jelr.IsEmpty() +func (page JobAgentListResultPage) NotDone() bool { + return !page.jalr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobExecutionListResultPage) Response() JobExecutionListResult { - return page.jelr +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 JobExecutionListResultPage) Values() []JobExecution { - if page.jelr.IsEmpty() { +func (page JobAgentListResultPage) Values() []JobAgent { + if page.jalr.IsEmpty() { return nil } - return *page.jelr.Value + return *page.jalr.Value } -// Creates a new instance of the JobExecutionListResultPage type. -func NewJobExecutionListResultPage(cur JobExecutionListResult, getNextPage func(context.Context, JobExecutionListResult) (JobExecutionListResult, error)) JobExecutionListResultPage { - return JobExecutionListResultPage{ +// Creates a new instance of the JobAgentListResultPage type. +func NewJobAgentListResultPage(cur JobAgentListResult, getNextPage func(context.Context, JobAgentListResult) (JobAgentListResult, error)) JobAgentListResultPage { + return JobAgentListResultPage{ fn: getNextPage, - jelr: cur, + jalr: cur, } } -// JobExecutionProperties properties for an Azure SQL Database Elastic job execution. -type JobExecutionProperties struct { - // JobVersion - READ-ONLY; The job version number. - JobVersion *int32 `json:"jobVersion,omitempty"` - // StepName - READ-ONLY; The job step name. - StepName *string `json:"stepName,omitempty"` - // StepID - READ-ONLY; The job step id. - StepID *int32 `json:"stepId,omitempty"` - // JobExecutionID - READ-ONLY; The unique identifier of the job execution. - JobExecutionID *uuid.UUID `json:"jobExecutionId,omitempty"` - // Lifecycle - READ-ONLY; The detailed state of the job execution. Possible values include: 'JobExecutionLifecycleCreated', 'JobExecutionLifecycleInProgress', 'JobExecutionLifecycleWaitingForChildJobExecutions', 'JobExecutionLifecycleWaitingForRetry', 'JobExecutionLifecycleSucceeded', 'JobExecutionLifecycleSucceededWithSkipped', 'JobExecutionLifecycleFailed', 'JobExecutionLifecycleTimedOut', 'JobExecutionLifecycleCanceled', 'JobExecutionLifecycleSkipped' - Lifecycle JobExecutionLifecycle `json:"lifecycle,omitempty"` - // ProvisioningState - READ-ONLY; The ARM provisioning state of the job execution. Possible values include: 'ProvisioningStateCreated', 'ProvisioningStateInProgress', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled' - ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - // CreateTime - READ-ONLY; The time that the job execution was created. - CreateTime *date.Time `json:"createTime,omitempty"` - // StartTime - READ-ONLY; The time that the job execution started. - StartTime *date.Time `json:"startTime,omitempty"` - // EndTime - READ-ONLY; 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 - READ-ONLY; Start time of the current attempt. - CurrentAttemptStartTime *date.Time `json:"currentAttemptStartTime,omitempty"` - // LastMessage - READ-ONLY; The last status or error message. - LastMessage *string `json:"lastMessage,omitempty"` - // Target - READ-ONLY; The target that this execution is executed on. - Target *JobExecutionTarget `json:"target,omitempty"` +// 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"` + // State - READ-ONLY; The state of the job agent. Possible values include: 'JobAgentStateCreating', 'JobAgentStateReady', 'JobAgentStateUpdating', 'JobAgentStateDeleting', 'JobAgentStateDisabled' + State JobAgentState `json:"state,omitempty"` } -// MarshalJSON is the custom marshaler for JobExecutionProperties. -func (jep JobExecutionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobAgentProperties. +func (jap JobAgentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if jep.CurrentAttempts != nil { - objectMap["currentAttempts"] = jep.CurrentAttempts + if jap.DatabaseID != nil { + objectMap["databaseId"] = jap.DatabaseID } return json.Marshal(objectMap) } -// JobExecutionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// JobAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. -type JobExecutionsCreateFuture struct { +type JobAgentsCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(JobExecutionsClient) (JobExecution, error) + Result func(JobAgentsClient) (JobAgent, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *JobExecutionsCreateFuture) UnmarshalJSON(body []byte) error { +func (future *JobAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -11117,40 +11911,40 @@ func (future *JobExecutionsCreateFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for JobExecutionsCreateFuture.Result. -func (future *JobExecutionsCreateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { +// result is the default implementation for JobAgentsCreateOrUpdateFuture.Result. +func (future *JobAgentsCreateOrUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - je.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateFuture") + ja.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { - je, err = client.CreateResponder(je.Response.Response) + if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { + ja, err = client.CreateOrUpdateResponder(ja.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", je.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") } } return } -// JobExecutionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type JobExecutionsCreateOrUpdateFuture struct { +// JobAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsDeleteFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(JobExecutionsClient) (JobExecution, error) + Result func(JobAgentsClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *JobExecutionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *JobAgentsDeleteFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -11160,80 +11954,189 @@ func (future *JobExecutionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) erro return nil } -// result is the default implementation for JobExecutionsCreateOrUpdateFuture.Result. -func (future *JobExecutionsCreateOrUpdateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { +// result is the default implementation for JobAgentsDeleteFuture.Result. +func (future *JobAgentsDeleteFuture) result(client JobAgentsClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { - je.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateOrUpdateFuture") + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// JobAgentsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (JobAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsUpdateFuture.Result. +func (future *JobAgentsUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ja.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { - je, err = client.CreateOrUpdateResponder(je.Response.Response) + if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { + ja, err = client.UpdateResponder(ja.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", je.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") } } return } -// JobExecutionTarget the target that a job execution is executed on. -type JobExecutionTarget struct { - // Type - READ-ONLY; The type of the target. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' - Type JobTargetType `json:"type,omitempty"` - // ServerName - READ-ONLY; The server name. - ServerName *string `json:"serverName,omitempty"` - // DatabaseName - READ-ONLY; The database name. - DatabaseName *string `json:"databaseName,omitempty"` +// JobAgentUpdate an update to an Azure SQL job agent. +type JobAgentUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` } -// MarshalJSON is the custom marshaler for JobExecutionTarget. -func (jet JobExecutionTarget) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobAgentUpdate. +func (jau JobAgentUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if jau.Tags != nil { + objectMap["tags"] = jau.Tags + } return json.Marshal(objectMap) } -// JobListResult a list of jobs. -type JobListResult struct { +// JobCredential a stored credential that can be used by a job to connect to target databases. +type JobCredential struct { autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]Job `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` + // JobCredentialProperties - Resource properties. + *JobCredentialProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for JobListResult. -func (jlr JobListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobCredential. +func (jc JobCredential) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if jc.JobCredentialProperties != nil { + objectMap["properties"] = jc.JobCredentialProperties + } return json.Marshal(objectMap) } -// JobListResultIterator provides access to a complete listing of Job values. -type JobListResultIterator struct { - i int - page JobListResultPage -} - -// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() +// 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 } - iter.i++ + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCredentialProperties JobCredentialProperties + err = json.Unmarshal(*v, &jobCredentialProperties) + if err != nil { + return err + } + jc.JobCredentialProperties = &jobCredentialProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jc.Type = &typeVar + } + } + } + + return nil +} + +// JobCredentialListResult a list of job credentials. +type JobCredentialListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobCredential `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCredentialListResult. +func (jclr JobCredentialListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobCredentialListResultIterator provides access to a complete listing of JobCredential values. +type JobCredentialListResultIterator struct { + i int + page JobCredentialListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ if iter.i < len(iter.page.Values()) { return nil } @@ -11249,67 +12152,67 @@ func (iter *JobListResultIterator) NextWithContext(ctx context.Context) (err err // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobListResultIterator) Next() error { +func (iter *JobCredentialListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobListResultIterator) NotDone() bool { +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 JobListResultIterator) Response() JobListResult { +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 JobListResultIterator) Value() Job { +func (iter JobCredentialListResultIterator) Value() JobCredential { if !iter.page.NotDone() { - return Job{} + return JobCredential{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobListResultIterator type. -func NewJobListResultIterator(page JobListResultPage) JobListResultIterator { - return JobListResultIterator{page: page} +// Creates a new instance of the JobCredentialListResultIterator type. +func NewJobCredentialListResultIterator(page JobCredentialListResultPage) JobCredentialListResultIterator { + return JobCredentialListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jlr JobListResult) IsEmpty() bool { - return jlr.Value == nil || len(*jlr.Value) == 0 +func (jclr JobCredentialListResult) IsEmpty() bool { + return jclr.Value == nil || len(*jclr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jlr JobListResult) hasNextLink() bool { - return jlr.NextLink != nil && len(*jlr.NextLink) != 0 +func (jclr JobCredentialListResult) hasNextLink() bool { + return jclr.NextLink != nil && len(*jclr.NextLink) != 0 } -// jobListResultPreparer prepares a request to retrieve the next set of results. +// jobCredentialListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jlr JobListResult) jobListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jlr.hasNextLink() { +func (jclr JobCredentialListResult) jobCredentialListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jclr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jlr.NextLink))) + autorest.WithBaseURL(to.String(jclr.NextLink))) } -// JobListResultPage contains a page of Job values. -type JobListResultPage struct { - fn func(context.Context, JobListResult) (JobListResult, error) - jlr JobListResult +// JobCredentialListResultPage contains a page of JobCredential values. +type JobCredentialListResultPage struct { + fn func(context.Context, JobCredentialListResult) (JobCredentialListResult, error) + jclr JobCredentialListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *JobCredentialListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -11319,11 +12222,11 @@ func (page *JobListResultPage) NextWithContext(ctx context.Context) (err error) }() } for { - next, err := page.fn(ctx, page.jlr) + next, err := page.fn(ctx, page.jclr) if err != nil { return err } - page.jlr = next + page.jclr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -11334,77 +12237,49 @@ func (page *JobListResultPage) NextWithContext(ctx context.Context) (err error) // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobListResultPage) Next() error { +func (page *JobCredentialListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobListResultPage) NotDone() bool { - return !page.jlr.IsEmpty() +func (page JobCredentialListResultPage) NotDone() bool { + return !page.jclr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobListResultPage) Response() JobListResult { - return page.jlr +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 JobListResultPage) Values() []Job { - if page.jlr.IsEmpty() { +func (page JobCredentialListResultPage) Values() []JobCredential { + if page.jclr.IsEmpty() { return nil } - return *page.jlr.Value -} - -// Creates a new instance of the JobListResultPage type. -func NewJobListResultPage(cur JobListResult, getNextPage func(context.Context, JobListResult) (JobListResult, error)) JobListResultPage { - return JobListResultPage{ - fn: getNextPage, - jlr: cur, - } -} - -// JobProperties properties of a job. -type JobProperties struct { - // Description - User-defined description of the job. - Description *string `json:"description,omitempty"` - // Version - READ-ONLY; The job version number. - Version *int32 `json:"version,omitempty"` - // Schedule - Schedule properties of the job. - Schedule *JobSchedule `json:"schedule,omitempty"` + return *page.jclr.Value } -// MarshalJSON is the custom marshaler for JobProperties. -func (jp JobProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if jp.Description != nil { - objectMap["description"] = jp.Description - } - if jp.Schedule != nil { - objectMap["schedule"] = jp.Schedule +// Creates a new instance of the JobCredentialListResultPage type. +func NewJobCredentialListResultPage(cur JobCredentialListResult, getNextPage func(context.Context, JobCredentialListResult) (JobCredentialListResult, error)) JobCredentialListResultPage { + return JobCredentialListResultPage{ + fn: getNextPage, + jclr: cur, } - return json.Marshal(objectMap) } -// 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: 'JobScheduleTypeOnce', 'JobScheduleTypeRecurring' - 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"` +// 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"` } -// JobStep a job step. -type JobStep struct { +// JobExecution an execution of a job +type JobExecution struct { autorest.Response `json:"-"` - // JobStepProperties - Resource properties. - *JobStepProperties `json:"properties,omitempty"` + // JobExecutionProperties - Resource properties. + *JobExecutionProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -11413,17 +12288,17 @@ type JobStep struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for JobStep. -func (js JobStep) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobExecution. +func (je JobExecution) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if js.JobStepProperties != nil { - objectMap["properties"] = js.JobStepProperties + if je.JobExecutionProperties != nil { + objectMap["properties"] = je.JobExecutionProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for JobStep struct. -func (js *JobStep) UnmarshalJSON(body []byte) error { +// 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 { @@ -11433,12 +12308,12 @@ func (js *JobStep) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var jobStepProperties JobStepProperties - err = json.Unmarshal(*v, &jobStepProperties) + var jobExecutionProperties JobExecutionProperties + err = json.Unmarshal(*v, &jobExecutionProperties) if err != nil { return err } - js.JobStepProperties = &jobStepProperties + je.JobExecutionProperties = &jobExecutionProperties } case "id": if v != nil { @@ -11447,7 +12322,7 @@ func (js *JobStep) UnmarshalJSON(body []byte) error { if err != nil { return err } - js.ID = &ID + je.ID = &ID } case "name": if v != nil { @@ -11456,7 +12331,7 @@ func (js *JobStep) UnmarshalJSON(body []byte) error { if err != nil { return err } - js.Name = &name + je.Name = &name } case "type": if v != nil { @@ -11465,7 +12340,7 @@ func (js *JobStep) UnmarshalJSON(body []byte) error { if err != nil { return err } - js.Type = &typeVar + je.Type = &typeVar } } } @@ -11473,56 +12348,32 @@ func (js *JobStep) UnmarshalJSON(body []byte) error { 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: 'JobStepActionTypeTSQL' - Type JobStepActionType `json:"type,omitempty"` - // Source - The source of the action to execute. Possible values include: 'JobStepActionSourceInline' - 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 { +// JobExecutionListResult a list of job executions. +type JobExecutionListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]JobStep `json:"value,omitempty"` + Value *[]JobExecution `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for JobStepListResult. -func (jslr JobStepListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobExecutionListResult. +func (jelr JobExecutionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// JobStepListResultIterator provides access to a complete listing of JobStep values. -type JobStepListResultIterator struct { +// JobExecutionListResultIterator provides access to a complete listing of JobExecution values. +type JobExecutionListResultIterator struct { i int - page JobStepListResultPage + page JobExecutionListResultPage } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (iter *JobExecutionListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -11547,67 +12398,67 @@ func (iter *JobStepListResultIterator) NextWithContext(ctx context.Context) (err // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobStepListResultIterator) Next() error { +func (iter *JobExecutionListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobStepListResultIterator) NotDone() bool { +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 JobStepListResultIterator) Response() JobStepListResult { +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 JobStepListResultIterator) Value() JobStep { +func (iter JobExecutionListResultIterator) Value() JobExecution { if !iter.page.NotDone() { - return JobStep{} + return JobExecution{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobStepListResultIterator type. -func NewJobStepListResultIterator(page JobStepListResultPage) JobStepListResultIterator { - return JobStepListResultIterator{page: page} +// Creates a new instance of the JobExecutionListResultIterator type. +func NewJobExecutionListResultIterator(page JobExecutionListResultPage) JobExecutionListResultIterator { + return JobExecutionListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jslr JobStepListResult) IsEmpty() bool { - return jslr.Value == nil || len(*jslr.Value) == 0 +func (jelr JobExecutionListResult) IsEmpty() bool { + return jelr.Value == nil || len(*jelr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jslr JobStepListResult) hasNextLink() bool { - return jslr.NextLink != nil && len(*jslr.NextLink) != 0 +func (jelr JobExecutionListResult) hasNextLink() bool { + return jelr.NextLink != nil && len(*jelr.NextLink) != 0 } -// jobStepListResultPreparer prepares a request to retrieve the next set of results. +// jobExecutionListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jslr JobStepListResult) jobStepListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jslr.hasNextLink() { +func (jelr JobExecutionListResult) jobExecutionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jelr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jslr.NextLink))) + autorest.WithBaseURL(to.String(jelr.NextLink))) } -// JobStepListResultPage contains a page of JobStep values. -type JobStepListResultPage struct { - fn func(context.Context, JobStepListResult) (JobStepListResult, error) - jslr JobStepListResult +// JobExecutionListResultPage contains a page of JobExecution values. +type JobExecutionListResultPage struct { + fn func(context.Context, JobExecutionListResult) (JobExecutionListResult, error) + jelr JobExecutionListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *JobExecutionListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -11617,11 +12468,11 @@ func (page *JobStepListResultPage) NextWithContext(ctx context.Context) (err err }() } for { - next, err := page.fn(ctx, page.jslr) + next, err := page.fn(ctx, page.jelr) if err != nil { return err } - page.jslr = next + page.jelr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -11632,190 +12483,203 @@ func (page *JobStepListResultPage) NextWithContext(ctx context.Context) (err err // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobStepListResultPage) Next() error { +func (page *JobExecutionListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobStepListResultPage) NotDone() bool { - return !page.jslr.IsEmpty() +func (page JobExecutionListResultPage) NotDone() bool { + return !page.jelr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobStepListResultPage) Response() JobStepListResult { - return page.jslr +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 JobStepListResultPage) Values() []JobStep { - if page.jslr.IsEmpty() { +func (page JobExecutionListResultPage) Values() []JobExecution { + if page.jelr.IsEmpty() { return nil } - return *page.jslr.Value + return *page.jelr.Value } -// Creates a new instance of the JobStepListResultPage type. -func NewJobStepListResultPage(cur JobStepListResult, getNextPage func(context.Context, JobStepListResult) (JobStepListResult, error)) JobStepListResultPage { - return JobStepListResultPage{ +// Creates a new instance of the JobExecutionListResultPage type. +func NewJobExecutionListResultPage(cur JobExecutionListResult, getNextPage func(context.Context, JobExecutionListResult) (JobExecutionListResult, error)) JobExecutionListResultPage { + return JobExecutionListResultPage{ fn: getNextPage, - jslr: cur, + jelr: cur, } } -// JobStepOutput the output configuration of a job step. -type JobStepOutput struct { - // Type - The output destination type. Possible values include: 'JobStepOutputTypeSQLDatabase' - Type JobStepOutputType `json:"type,omitempty"` - // SubscriptionID - The output destination subscription id. - SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` - // ResourceGroupName - The output destination resource group. - ResourceGroupName *string `json:"resourceGroupName,omitempty"` - // ServerName - The output destination server name. - ServerName *string `json:"serverName,omitempty"` - // DatabaseName - The output destination database. - DatabaseName *string `json:"databaseName,omitempty"` - // SchemaName - The output destination schema. - SchemaName *string `json:"schemaName,omitempty"` - // TableName - The output destination table. - TableName *string `json:"tableName,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. +// JobExecutionProperties properties for an Azure SQL Database Elastic job execution. +type JobExecutionProperties struct { + // JobVersion - READ-ONLY; The job version number. + JobVersion *int32 `json:"jobVersion,omitempty"` + // StepName - READ-ONLY; The job step name. + StepName *string `json:"stepName,omitempty"` + // StepID - READ-ONLY; The job step id. 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: 'JobTargetGroupMembershipTypeInclude', 'JobTargetGroupMembershipTypeExclude' - 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:"-"` - // JobTargetGroupProperties - Resource properties. - *JobTargetGroupProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` + // JobExecutionID - READ-ONLY; The unique identifier of the job execution. + JobExecutionID *uuid.UUID `json:"jobExecutionId,omitempty"` + // Lifecycle - READ-ONLY; The detailed state of the job execution. Possible values include: 'JobExecutionLifecycleCreated', 'JobExecutionLifecycleInProgress', 'JobExecutionLifecycleWaitingForChildJobExecutions', 'JobExecutionLifecycleWaitingForRetry', 'JobExecutionLifecycleSucceeded', 'JobExecutionLifecycleSucceededWithSkipped', 'JobExecutionLifecycleFailed', 'JobExecutionLifecycleTimedOut', 'JobExecutionLifecycleCanceled', 'JobExecutionLifecycleSkipped' + Lifecycle JobExecutionLifecycle `json:"lifecycle,omitempty"` + // ProvisioningState - READ-ONLY; The ARM provisioning state of the job execution. Possible values include: 'ProvisioningStateCreated', 'ProvisioningStateInProgress', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // CreateTime - READ-ONLY; The time that the job execution was created. + CreateTime *date.Time `json:"createTime,omitempty"` + // StartTime - READ-ONLY; The time that the job execution started. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; 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 - READ-ONLY; Start time of the current attempt. + CurrentAttemptStartTime *date.Time `json:"currentAttemptStartTime,omitempty"` + // LastMessage - READ-ONLY; The last status or error message. + LastMessage *string `json:"lastMessage,omitempty"` + // Target - READ-ONLY; The target that this execution is executed on. + Target *JobExecutionTarget `json:"target,omitempty"` } -// MarshalJSON is the custom marshaler for JobTargetGroup. -func (jtg JobTargetGroup) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobExecutionProperties. +func (jep JobExecutionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if jtg.JobTargetGroupProperties != nil { - objectMap["properties"] = jtg.JobTargetGroupProperties + if jep.CurrentAttempts != nil { + objectMap["currentAttempts"] = jep.CurrentAttempts } return json.Marshal(objectMap) } -// 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 { +// JobExecutionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobExecutionsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobExecutionsClient) (JobExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobExecutionsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { return err } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var jobTargetGroupProperties JobTargetGroupProperties - err = json.Unmarshal(*v, &jobTargetGroupProperties) - if err != nil { - return err - } - jtg.JobTargetGroupProperties = &jobTargetGroupProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - jtg.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - jtg.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - jtg.Type = &typeVar - } - } - } - + future.FutureAPI = &azFuture + future.Result = future.result return nil } -// JobTargetGroupListResult a list of target groups. -type JobTargetGroupListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]JobTargetGroup `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for JobTargetGroupListResult. -func (jtglr JobTargetGroupListResult) MarshalJSON() ([]byte, error) { +// result is the default implementation for JobExecutionsCreateFuture.Result. +func (future *JobExecutionsCreateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + je.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { + je, err = client.CreateResponder(je.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", je.Response.Response, "Failure responding to request") + } + } + return +} + +// JobExecutionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type JobExecutionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobExecutionsClient) (JobExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobExecutionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobExecutionsCreateOrUpdateFuture.Result. +func (future *JobExecutionsCreateOrUpdateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + je.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { + je, err = client.CreateOrUpdateResponder(je.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", je.Response.Response, "Failure responding to request") + } + } + return +} + +// JobExecutionTarget the target that a job execution is executed on. +type JobExecutionTarget struct { + // Type - READ-ONLY; The type of the target. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' + Type JobTargetType `json:"type,omitempty"` + // ServerName - READ-ONLY; The server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionTarget. +func (jet JobExecutionTarget) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// JobTargetGroupListResultIterator provides access to a complete listing of JobTargetGroup values. -type JobTargetGroupListResultIterator struct { +// JobListResult a list of jobs. +type JobListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Job `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobListResult. +func (jlr JobListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobListResultIterator provides access to a complete listing of Job values. +type JobListResultIterator struct { i int - page JobTargetGroupListResultPage + page JobListResultPage } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (iter *JobListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -11840,67 +12704,67 @@ func (iter *JobTargetGroupListResultIterator) NextWithContext(ctx context.Contex // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobTargetGroupListResultIterator) Next() error { +func (iter *JobListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobTargetGroupListResultIterator) NotDone() bool { +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 JobTargetGroupListResultIterator) Response() JobTargetGroupListResult { +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 JobTargetGroupListResultIterator) Value() JobTargetGroup { +func (iter JobListResultIterator) Value() Job { if !iter.page.NotDone() { - return JobTargetGroup{} + return Job{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobTargetGroupListResultIterator type. -func NewJobTargetGroupListResultIterator(page JobTargetGroupListResultPage) JobTargetGroupListResultIterator { - return JobTargetGroupListResultIterator{page: page} +// Creates a new instance of the JobListResultIterator type. +func NewJobListResultIterator(page JobListResultPage) JobListResultIterator { + return JobListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jtglr JobTargetGroupListResult) IsEmpty() bool { - return jtglr.Value == nil || len(*jtglr.Value) == 0 +func (jlr JobListResult) IsEmpty() bool { + return jlr.Value == nil || len(*jlr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jtglr JobTargetGroupListResult) hasNextLink() bool { - return jtglr.NextLink != nil && len(*jtglr.NextLink) != 0 +func (jlr JobListResult) hasNextLink() bool { + return jlr.NextLink != nil && len(*jlr.NextLink) != 0 } -// jobTargetGroupListResultPreparer prepares a request to retrieve the next set of results. +// jobListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jtglr JobTargetGroupListResult) jobTargetGroupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jtglr.hasNextLink() { +func (jlr JobListResult) jobListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jtglr.NextLink))) + autorest.WithBaseURL(to.String(jlr.NextLink))) } -// JobTargetGroupListResultPage contains a page of JobTargetGroup values. -type JobTargetGroupListResultPage struct { - fn func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error) - jtglr JobTargetGroupListResult +// JobListResultPage contains a page of Job values. +type JobListResultPage struct { + fn func(context.Context, JobListResult) (JobListResult, error) + jlr JobListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *JobListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -11910,11 +12774,11 @@ func (page *JobTargetGroupListResultPage) NextWithContext(ctx context.Context) ( }() } for { - next, err := page.fn(ctx, page.jtglr) + next, err := page.fn(ctx, page.jlr) if err != nil { return err } - page.jtglr = next + page.jlr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -11925,45 +12789,77 @@ func (page *JobTargetGroupListResultPage) NextWithContext(ctx context.Context) ( // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobTargetGroupListResultPage) Next() error { +func (page *JobListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobTargetGroupListResultPage) NotDone() bool { - return !page.jtglr.IsEmpty() +func (page JobListResultPage) NotDone() bool { + return !page.jlr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobTargetGroupListResultPage) Response() JobTargetGroupListResult { - return page.jtglr +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 JobTargetGroupListResultPage) Values() []JobTargetGroup { - if page.jtglr.IsEmpty() { +func (page JobListResultPage) Values() []Job { + if page.jlr.IsEmpty() { return nil } - return *page.jtglr.Value + return *page.jlr.Value } -// Creates a new instance of the JobTargetGroupListResultPage type. -func NewJobTargetGroupListResultPage(cur JobTargetGroupListResult, getNextPage func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error)) JobTargetGroupListResultPage { - return JobTargetGroupListResultPage{ - fn: getNextPage, - jtglr: cur, +// Creates a new instance of the JobListResultPage type. +func NewJobListResultPage(cur JobListResult, getNextPage func(context.Context, JobListResult) (JobListResult, error)) JobListResultPage { + return JobListResultPage{ + fn: getNextPage, + jlr: cur, } } -// JobTargetGroupProperties properties of job target group. -type JobTargetGroupProperties struct { - // Members - Members of the target group. - Members *[]JobTarget `json:"members,omitempty"` +// JobProperties properties of a job. +type JobProperties struct { + // Description - User-defined description of the job. + Description *string `json:"description,omitempty"` + // Version - READ-ONLY; The job version number. + Version *int32 `json:"version,omitempty"` + // Schedule - Schedule properties of the job. + Schedule *JobSchedule `json:"schedule,omitempty"` } -// JobVersion a job version. -type JobVersion struct { +// MarshalJSON is the custom marshaler for JobProperties. +func (jp JobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jp.Description != nil { + objectMap["description"] = jp.Description + } + if jp.Schedule != nil { + objectMap["schedule"] = jp.Schedule + } + return json.Marshal(objectMap) +} + +// 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: 'JobScheduleTypeOnce', 'JobScheduleTypeRecurring' + 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:"-"` + // JobStepProperties - Resource properties. + *JobStepProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -11972,39 +12868,117 @@ type JobVersion struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for JobVersion. -func (jv JobVersion) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// JobVersionListResult a list of job versions. -type JobVersionListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]JobVersion `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for JobVersionListResult. -func (jvlr JobVersionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobStep. +func (js JobStep) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if js.JobStepProperties != nil { + objectMap["properties"] = js.JobStepProperties + } return json.Marshal(objectMap) } -// JobVersionListResultIterator provides access to a complete listing of JobVersion values. -type JobVersionListResultIterator struct { - i int - page JobVersionListResultPage -} - -// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultIterator.NextWithContext") - defer func() { +// 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 + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobStepProperties JobStepProperties + err = json.Unmarshal(*v, &jobStepProperties) + if err != nil { + return err + } + js.JobStepProperties = &jobStepProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + js.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &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: 'JobStepActionTypeTSQL' + Type JobStepActionType `json:"type,omitempty"` + // Source - The source of the action to execute. Possible values include: 'JobStepActionSourceInline' + 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 - READ-ONLY; Array of results. + Value *[]JobStep `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStepListResult. +func (jslr JobStepListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobStepListResultIterator provides access to a complete listing of JobStep values. +type JobStepListResultIterator struct { + i int + page JobStepListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultIterator.NextWithContext") + defer func() { sc := -1 if iter.Response().Response.Response != nil { sc = iter.Response().Response.Response.StatusCode @@ -12028,67 +13002,67 @@ func (iter *JobVersionListResultIterator) NextWithContext(ctx context.Context) ( // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *JobVersionListResultIterator) Next() error { +func (iter *JobStepListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter JobVersionListResultIterator) NotDone() bool { +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 JobVersionListResultIterator) Response() JobVersionListResult { +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 JobVersionListResultIterator) Value() JobVersion { +func (iter JobStepListResultIterator) Value() JobStep { if !iter.page.NotDone() { - return JobVersion{} + return JobStep{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the JobVersionListResultIterator type. -func NewJobVersionListResultIterator(page JobVersionListResultPage) JobVersionListResultIterator { - return JobVersionListResultIterator{page: page} +// Creates a new instance of the JobStepListResultIterator type. +func NewJobStepListResultIterator(page JobStepListResultPage) JobStepListResultIterator { + return JobStepListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (jvlr JobVersionListResult) IsEmpty() bool { - return jvlr.Value == nil || len(*jvlr.Value) == 0 +func (jslr JobStepListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (jvlr JobVersionListResult) hasNextLink() bool { - return jvlr.NextLink != nil && len(*jvlr.NextLink) != 0 +func (jslr JobStepListResult) hasNextLink() bool { + return jslr.NextLink != nil && len(*jslr.NextLink) != 0 } -// jobVersionListResultPreparer prepares a request to retrieve the next set of results. +// jobStepListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (jvlr JobVersionListResult) jobVersionListResultPreparer(ctx context.Context) (*http.Request, error) { - if !jvlr.hasNextLink() { +func (jslr JobStepListResult) jobStepListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jslr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(jvlr.NextLink))) + autorest.WithBaseURL(to.String(jslr.NextLink))) } -// JobVersionListResultPage contains a page of JobVersion values. -type JobVersionListResultPage struct { - fn func(context.Context, JobVersionListResult) (JobVersionListResult, error) - jvlr JobVersionListResult +// JobStepListResultPage contains a page of JobStep values. +type JobStepListResultPage struct { + fn func(context.Context, JobStepListResult) (JobStepListResult, error) + jslr JobStepListResult } // NextWithContext 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) NextWithContext(ctx context.Context) (err error) { +func (page *JobStepListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -12098,11 +13072,11 @@ func (page *JobVersionListResultPage) NextWithContext(ctx context.Context) (err }() } for { - next, err := page.fn(ctx, page.jvlr) + next, err := page.fn(ctx, page.jslr) if err != nil { return err } - page.jvlr = next + page.jslr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -12113,41 +13087,96 @@ func (page *JobVersionListResultPage) NextWithContext(ctx context.Context) (err // 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. // Deprecated: Use NextWithContext() instead. -func (page *JobVersionListResultPage) Next() error { +func (page *JobStepListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page JobVersionListResultPage) NotDone() bool { - return !page.jvlr.IsEmpty() +func (page JobStepListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page JobVersionListResultPage) Response() JobVersionListResult { - return page.jvlr +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 JobVersionListResultPage) Values() []JobVersion { - if page.jvlr.IsEmpty() { +func (page JobStepListResultPage) Values() []JobStep { + if page.jslr.IsEmpty() { return nil } - return *page.jvlr.Value + return *page.jslr.Value } -// Creates a new instance of the JobVersionListResultPage type. -func NewJobVersionListResultPage(cur JobVersionListResult, getNextPage func(context.Context, JobVersionListResult) (JobVersionListResult, error)) JobVersionListResultPage { - return JobVersionListResultPage{ +// Creates a new instance of the JobStepListResultPage type. +func NewJobStepListResultPage(cur JobStepListResult, getNextPage func(context.Context, JobStepListResult) (JobStepListResult, error)) JobStepListResultPage { + return JobStepListResultPage{ fn: getNextPage, - jvlr: cur, + jslr: cur, } } -// LedgerDigestUploads azure SQL Database ledger digest upload settings. -type LedgerDigestUploads struct { +// JobStepOutput the output configuration of a job step. +type JobStepOutput struct { + // Type - The output destination type. Possible values include: 'JobStepOutputTypeSQLDatabase' + Type JobStepOutputType `json:"type,omitempty"` + // SubscriptionID - The output destination subscription id. + SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` + // ResourceGroupName - The output destination resource group. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ServerName - The output destination server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The output destination database. + DatabaseName *string `json:"databaseName,omitempty"` + // SchemaName - The output destination schema. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - The output destination table. + TableName *string `json:"tableName,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: 'JobTargetGroupMembershipTypeInclude', 'JobTargetGroupMembershipTypeExclude' + 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:"-"` - // LedgerDigestUploadsProperties - Resource properties. - *LedgerDigestUploadsProperties `json:"properties,omitempty"` + // JobTargetGroupProperties - Resource properties. + *JobTargetGroupProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -12156,17 +13185,17 @@ type LedgerDigestUploads struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for LedgerDigestUploads. -func (ldu LedgerDigestUploads) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobTargetGroup. +func (jtg JobTargetGroup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ldu.LedgerDigestUploadsProperties != nil { - objectMap["properties"] = ldu.LedgerDigestUploadsProperties + if jtg.JobTargetGroupProperties != nil { + objectMap["properties"] = jtg.JobTargetGroupProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for LedgerDigestUploads struct. -func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { +// 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 { @@ -12176,12 +13205,12 @@ func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var ledgerDigestUploadsProperties LedgerDigestUploadsProperties - err = json.Unmarshal(*v, &ledgerDigestUploadsProperties) + var jobTargetGroupProperties JobTargetGroupProperties + err = json.Unmarshal(*v, &jobTargetGroupProperties) if err != nil { return err } - ldu.LedgerDigestUploadsProperties = &ledgerDigestUploadsProperties + jtg.JobTargetGroupProperties = &jobTargetGroupProperties } case "id": if v != nil { @@ -12190,7 +13219,7 @@ func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { if err != nil { return err } - ldu.ID = &ID + jtg.ID = &ID } case "name": if v != nil { @@ -12199,7 +13228,7 @@ func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { if err != nil { return err } - ldu.Name = &name + jtg.Name = &name } case "type": if v != nil { @@ -12208,7 +13237,7 @@ func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { if err != nil { return err } - ldu.Type = &typeVar + jtg.Type = &typeVar } } } @@ -12216,33 +13245,32 @@ func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { return nil } -// LedgerDigestUploadsListResult a list of ledger digest upload settings. -type LedgerDigestUploadsListResult struct { +// JobTargetGroupListResult a list of target groups. +type JobTargetGroupListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]LedgerDigestUploads `json:"value,omitempty"` + Value *[]JobTargetGroup `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for LedgerDigestUploadsListResult. -func (ldulr LedgerDigestUploadsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobTargetGroupListResult. +func (jtglr JobTargetGroupListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// LedgerDigestUploadsListResultIterator provides access to a complete listing of LedgerDigestUploads -// values. -type LedgerDigestUploadsListResultIterator struct { +// JobTargetGroupListResultIterator provides access to a complete listing of JobTargetGroup values. +type JobTargetGroupListResultIterator struct { i int - page LedgerDigestUploadsListResultPage + page JobTargetGroupListResultPage } // NextWithContext 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 *LedgerDigestUploadsListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *JobTargetGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -12267,67 +13295,67 @@ func (iter *LedgerDigestUploadsListResultIterator) NextWithContext(ctx context.C // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *LedgerDigestUploadsListResultIterator) Next() error { +func (iter *JobTargetGroupListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter LedgerDigestUploadsListResultIterator) NotDone() bool { +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 LedgerDigestUploadsListResultIterator) Response() LedgerDigestUploadsListResult { +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 LedgerDigestUploadsListResultIterator) Value() LedgerDigestUploads { +func (iter JobTargetGroupListResultIterator) Value() JobTargetGroup { if !iter.page.NotDone() { - return LedgerDigestUploads{} + return JobTargetGroup{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the LedgerDigestUploadsListResultIterator type. -func NewLedgerDigestUploadsListResultIterator(page LedgerDigestUploadsListResultPage) LedgerDigestUploadsListResultIterator { - return LedgerDigestUploadsListResultIterator{page: page} +// Creates a new instance of the JobTargetGroupListResultIterator type. +func NewJobTargetGroupListResultIterator(page JobTargetGroupListResultPage) JobTargetGroupListResultIterator { + return JobTargetGroupListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (ldulr LedgerDigestUploadsListResult) IsEmpty() bool { - return ldulr.Value == nil || len(*ldulr.Value) == 0 +func (jtglr JobTargetGroupListResult) IsEmpty() bool { + return jtglr.Value == nil || len(*jtglr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (ldulr LedgerDigestUploadsListResult) hasNextLink() bool { - return ldulr.NextLink != nil && len(*ldulr.NextLink) != 0 +func (jtglr JobTargetGroupListResult) hasNextLink() bool { + return jtglr.NextLink != nil && len(*jtglr.NextLink) != 0 } -// ledgerDigestUploadsListResultPreparer prepares a request to retrieve the next set of results. +// jobTargetGroupListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (ldulr LedgerDigestUploadsListResult) ledgerDigestUploadsListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ldulr.hasNextLink() { +func (jtglr JobTargetGroupListResult) jobTargetGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jtglr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(ldulr.NextLink))) + autorest.WithBaseURL(to.String(jtglr.NextLink))) } -// LedgerDigestUploadsListResultPage contains a page of LedgerDigestUploads values. -type LedgerDigestUploadsListResultPage struct { - fn func(context.Context, LedgerDigestUploadsListResult) (LedgerDigestUploadsListResult, error) - ldulr LedgerDigestUploadsListResult +// JobTargetGroupListResultPage contains a page of JobTargetGroup values. +type JobTargetGroupListResultPage struct { + fn func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error) + jtglr JobTargetGroupListResult } // NextWithContext 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 *LedgerDigestUploadsListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *JobTargetGroupListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -12337,11 +13365,11 @@ func (page *LedgerDigestUploadsListResultPage) NextWithContext(ctx context.Conte }() } for { - next, err := page.fn(ctx, page.ldulr) + next, err := page.fn(ctx, page.jtglr) if err != nil { return err } - page.ldulr = next + page.jtglr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -12352,135 +13380,85 @@ func (page *LedgerDigestUploadsListResultPage) NextWithContext(ctx context.Conte // 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. // Deprecated: Use NextWithContext() instead. -func (page *LedgerDigestUploadsListResultPage) Next() error { +func (page *JobTargetGroupListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page LedgerDigestUploadsListResultPage) NotDone() bool { - return !page.ldulr.IsEmpty() +func (page JobTargetGroupListResultPage) NotDone() bool { + return !page.jtglr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page LedgerDigestUploadsListResultPage) Response() LedgerDigestUploadsListResult { - return page.ldulr +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 LedgerDigestUploadsListResultPage) Values() []LedgerDigestUploads { - if page.ldulr.IsEmpty() { +func (page JobTargetGroupListResultPage) Values() []JobTargetGroup { + if page.jtglr.IsEmpty() { return nil } - return *page.ldulr.Value + return *page.jtglr.Value } -// Creates a new instance of the LedgerDigestUploadsListResultPage type. -func NewLedgerDigestUploadsListResultPage(cur LedgerDigestUploadsListResult, getNextPage func(context.Context, LedgerDigestUploadsListResult) (LedgerDigestUploadsListResult, error)) LedgerDigestUploadsListResultPage { - return LedgerDigestUploadsListResultPage{ +// Creates a new instance of the JobTargetGroupListResultPage type. +func NewJobTargetGroupListResultPage(cur JobTargetGroupListResult, getNextPage func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error)) JobTargetGroupListResultPage { + return JobTargetGroupListResultPage{ fn: getNextPage, - ldulr: cur, - } -} - -// LedgerDigestUploadsProperties the properties of a database ledger digest upload settings. -type LedgerDigestUploadsProperties struct { - // DigestStorageEndpoint - The digest storage endpoint, which must be either an Azure blob storage endpoint or an URI for Azure Confidential Ledger. - DigestStorageEndpoint *string `json:"digestStorageEndpoint,omitempty"` - // State - READ-ONLY; Specifies the state of ledger digest upload. Possible values include: 'LedgerDigestUploadsStateEnabled', 'LedgerDigestUploadsStateDisabled' - State LedgerDigestUploadsState `json:"state,omitempty"` -} - -// MarshalJSON is the custom marshaler for LedgerDigestUploadsProperties. -func (ldup LedgerDigestUploadsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ldup.DigestStorageEndpoint != nil { - objectMap["digestStorageEndpoint"] = ldup.DigestStorageEndpoint - } - return json.Marshal(objectMap) -} - -// LicenseTypeCapability the license type capability -type LicenseTypeCapability struct { - // Name - READ-ONLY; License type identifier. - Name *string `json:"name,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for LicenseTypeCapability. -func (ltc LicenseTypeCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ltc.Reason != nil { - objectMap["reason"] = ltc.Reason + jtglr: cur, } - return json.Marshal(objectMap) -} - -// ListAdvisor ... -type ListAdvisor struct { - autorest.Response `json:"-"` - Value *[]Advisor `json:"value,omitempty"` } -// ListRecommendedAction ... -type ListRecommendedAction struct { - autorest.Response `json:"-"` - Value *[]RecommendedAction `json:"value,omitempty"` +// JobTargetGroupProperties properties of job target group. +type JobTargetGroupProperties struct { + // Members - Members of the target group. + Members *[]JobTarget `json:"members,omitempty"` } -// LocationCapabilities the location capability. -type LocationCapabilities struct { +// JobVersion a job version. +type JobVersion struct { autorest.Response `json:"-"` - // Name - READ-ONLY; The location name. + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. Name *string `json:"name,omitempty"` - // SupportedServerVersions - READ-ONLY; The list of supported server versions. - SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` - // SupportedManagedInstanceVersions - READ-ONLY; The list of supported managed instance versions. - SupportedManagedInstanceVersions *[]ManagedInstanceVersionCapability `json:"supportedManagedInstanceVersions,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for LocationCapabilities. -func (lc LocationCapabilities) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobVersion. +func (jv JobVersion) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if lc.Reason != nil { - objectMap["reason"] = lc.Reason - } return json.Marshal(objectMap) } -// LogicalServerSecurityAlertPolicyListResult a list of the server's security alert policies. -type LogicalServerSecurityAlertPolicyListResult struct { +// JobVersionListResult a list of job versions. +type JobVersionListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` + Value *[]JobVersion `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for LogicalServerSecurityAlertPolicyListResult. -func (lssaplr LogicalServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for JobVersionListResult. +func (jvlr JobVersionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// LogicalServerSecurityAlertPolicyListResultIterator provides access to a complete listing of -// ServerSecurityAlertPolicy values. -type LogicalServerSecurityAlertPolicyListResultIterator struct { +// JobVersionListResultIterator provides access to a complete listing of JobVersion values. +type JobVersionListResultIterator struct { i int - page LogicalServerSecurityAlertPolicyListResultPage + page JobVersionListResultPage } // NextWithContext 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 *LogicalServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *JobVersionListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -12505,67 +13483,67 @@ func (iter *LogicalServerSecurityAlertPolicyListResultIterator) NextWithContext( // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *LogicalServerSecurityAlertPolicyListResultIterator) Next() error { +func (iter *JobVersionListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter LogicalServerSecurityAlertPolicyListResultIterator) NotDone() bool { +func (iter JobVersionListResultIterator) 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 LogicalServerSecurityAlertPolicyListResultIterator) Response() LogicalServerSecurityAlertPolicyListResult { +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 LogicalServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { +func (iter JobVersionListResultIterator) Value() JobVersion { if !iter.page.NotDone() { - return ServerSecurityAlertPolicy{} + return JobVersion{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultIterator type. -func NewLogicalServerSecurityAlertPolicyListResultIterator(page LogicalServerSecurityAlertPolicyListResultPage) LogicalServerSecurityAlertPolicyListResultIterator { - return LogicalServerSecurityAlertPolicyListResultIterator{page: page} +// Creates a new instance of the JobVersionListResultIterator type. +func NewJobVersionListResultIterator(page JobVersionListResultPage) JobVersionListResultIterator { + return JobVersionListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (lssaplr LogicalServerSecurityAlertPolicyListResult) IsEmpty() bool { - return lssaplr.Value == nil || len(*lssaplr.Value) == 0 +func (jvlr JobVersionListResult) IsEmpty() bool { + return jvlr.Value == nil || len(*jvlr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (lssaplr LogicalServerSecurityAlertPolicyListResult) hasNextLink() bool { - return lssaplr.NextLink != nil && len(*lssaplr.NextLink) != 0 +func (jvlr JobVersionListResult) hasNextLink() bool { + return jvlr.NextLink != nil && len(*jvlr.NextLink) != 0 } -// logicalServerSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// jobVersionListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (lssaplr LogicalServerSecurityAlertPolicyListResult) logicalServerSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !lssaplr.hasNextLink() { +func (jvlr JobVersionListResult) jobVersionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jvlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(lssaplr.NextLink))) + autorest.WithBaseURL(to.String(jvlr.NextLink))) } -// LogicalServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. -type LogicalServerSecurityAlertPolicyListResultPage struct { - fn func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error) - lssaplr LogicalServerSecurityAlertPolicyListResult +// JobVersionListResultPage contains a page of JobVersion values. +type JobVersionListResultPage struct { + fn func(context.Context, JobVersionListResult) (JobVersionListResult, error) + jvlr JobVersionListResult } // NextWithContext 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 *LogicalServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *JobVersionListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -12575,11 +13553,11 @@ func (page *LogicalServerSecurityAlertPolicyListResultPage) NextWithContext(ctx }() } for { - next, err := page.fn(ctx, page.lssaplr) + next, err := page.fn(ctx, page.jvlr) if err != nil { return err } - page.lssaplr = next + page.jvlr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -12590,55 +13568,41 @@ func (page *LogicalServerSecurityAlertPolicyListResultPage) NextWithContext(ctx // 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. // Deprecated: Use NextWithContext() instead. -func (page *LogicalServerSecurityAlertPolicyListResultPage) Next() error { +func (page *JobVersionListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page LogicalServerSecurityAlertPolicyListResultPage) NotDone() bool { - return !page.lssaplr.IsEmpty() +func (page JobVersionListResultPage) NotDone() bool { + return !page.jvlr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page LogicalServerSecurityAlertPolicyListResultPage) Response() LogicalServerSecurityAlertPolicyListResult { - return page.lssaplr +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 LogicalServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { - if page.lssaplr.IsEmpty() { +func (page JobVersionListResultPage) Values() []JobVersion { + if page.jvlr.IsEmpty() { return nil } - return *page.lssaplr.Value + return *page.jvlr.Value } -// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultPage type. -func NewLogicalServerSecurityAlertPolicyListResultPage(cur LogicalServerSecurityAlertPolicyListResult, getNextPage func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error)) LogicalServerSecurityAlertPolicyListResultPage { - return LogicalServerSecurityAlertPolicyListResultPage{ - fn: getNextPage, - lssaplr: cur, +// Creates a new instance of the JobVersionListResultPage type. +func NewJobVersionListResultPage(cur JobVersionListResult, getNextPage func(context.Context, JobVersionListResult) (JobVersionListResult, error)) JobVersionListResultPage { + return JobVersionListResultPage{ + fn: getNextPage, + jvlr: cur, } } -// LogSizeCapability the log size capability. -type LogSizeCapability struct { - // Limit - READ-ONLY; The log size limit (see 'unit' for the units). - Limit *int32 `json:"limit,omitempty"` - // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'LogSizeUnitMegabytes', 'LogSizeUnitGigabytes', 'LogSizeUnitTerabytes', 'LogSizeUnitPetabytes', 'LogSizeUnitPercent' - Unit LogSizeUnit `json:"unit,omitempty"` -} - -// MarshalJSON is the custom marshaler for LogSizeCapability. -func (lsc LogSizeCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// LongTermRetentionBackup a long term retention backup. -type LongTermRetentionBackup struct { +// LedgerDigestUploads azure SQL Database ledger digest upload settings. +type LedgerDigestUploads struct { autorest.Response `json:"-"` - // LongTermRetentionBackupProperties - Resource properties. - *LongTermRetentionBackupProperties `json:"properties,omitempty"` + // LedgerDigestUploadsProperties - Resource properties. + *LedgerDigestUploadsProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -12647,17 +13611,17 @@ type LongTermRetentionBackup struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for LongTermRetentionBackup. -func (ltrb LongTermRetentionBackup) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LedgerDigestUploads. +func (ldu LedgerDigestUploads) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ltrb.LongTermRetentionBackupProperties != nil { - objectMap["properties"] = ltrb.LongTermRetentionBackupProperties + if ldu.LedgerDigestUploadsProperties != nil { + objectMap["properties"] = ldu.LedgerDigestUploadsProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackup struct. -func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for LedgerDigestUploads struct. +func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -12667,12 +13631,12 @@ func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var longTermRetentionBackupProperties LongTermRetentionBackupProperties - err = json.Unmarshal(*v, &longTermRetentionBackupProperties) + var ledgerDigestUploadsProperties LedgerDigestUploadsProperties + err = json.Unmarshal(*v, &ledgerDigestUploadsProperties) if err != nil { return err } - ltrb.LongTermRetentionBackupProperties = &longTermRetentionBackupProperties + ldu.LedgerDigestUploadsProperties = &ledgerDigestUploadsProperties } case "id": if v != nil { @@ -12681,7 +13645,7 @@ func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { if err != nil { return err } - ltrb.ID = &ID + ldu.ID = &ID } case "name": if v != nil { @@ -12690,7 +13654,7 @@ func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { if err != nil { return err } - ltrb.Name = &name + ldu.Name = &name } case "type": if v != nil { @@ -12699,7 +13663,7 @@ func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { if err != nil { return err } - ltrb.Type = &typeVar + ldu.Type = &typeVar } } } @@ -12707,33 +13671,119 @@ func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { return nil } -// LongTermRetentionBackupListResult a list of long term retention backups. -type LongTermRetentionBackupListResult struct { +// LedgerDigestUploadsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LedgerDigestUploadsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LedgerDigestUploadsClient) (LedgerDigestUploads, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LedgerDigestUploadsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LedgerDigestUploadsCreateOrUpdateFuture.Result. +func (future *LedgerDigestUploadsCreateOrUpdateFuture) result(client LedgerDigestUploadsClient) (ldu LedgerDigestUploads, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ldu.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LedgerDigestUploadsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ldu.Response.Response, err = future.GetResult(sender); err == nil && ldu.Response.Response.StatusCode != http.StatusNoContent { + ldu, err = client.CreateOrUpdateResponder(ldu.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsCreateOrUpdateFuture", "Result", ldu.Response.Response, "Failure responding to request") + } + } + return +} + +// LedgerDigestUploadsDisableFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LedgerDigestUploadsDisableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LedgerDigestUploadsClient) (LedgerDigestUploads, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LedgerDigestUploadsDisableFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LedgerDigestUploadsDisableFuture.Result. +func (future *LedgerDigestUploadsDisableFuture) result(client LedgerDigestUploadsClient) (ldu LedgerDigestUploads, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsDisableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ldu.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LedgerDigestUploadsDisableFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ldu.Response.Response, err = future.GetResult(sender); err == nil && ldu.Response.Response.StatusCode != http.StatusNoContent { + ldu, err = client.DisableResponder(ldu.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsDisableFuture", "Result", ldu.Response.Response, "Failure responding to request") + } + } + return +} + +// LedgerDigestUploadsListResult a list of ledger digest upload settings. +type LedgerDigestUploadsListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]LongTermRetentionBackup `json:"value,omitempty"` + Value *[]LedgerDigestUploads `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for LongTermRetentionBackupListResult. -func (ltrblr LongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LedgerDigestUploadsListResult. +func (ldulr LedgerDigestUploadsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// LongTermRetentionBackupListResultIterator provides access to a complete listing of -// LongTermRetentionBackup values. -type LongTermRetentionBackupListResultIterator struct { +// LedgerDigestUploadsListResultIterator provides access to a complete listing of LedgerDigestUploads +// values. +type LedgerDigestUploadsListResultIterator struct { i int - page LongTermRetentionBackupListResultPage + page LedgerDigestUploadsListResultPage } // NextWithContext 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 *LongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *LedgerDigestUploadsListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -12758,67 +13808,67 @@ func (iter *LongTermRetentionBackupListResultIterator) NextWithContext(ctx conte // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *LongTermRetentionBackupListResultIterator) Next() error { +func (iter *LedgerDigestUploadsListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter LongTermRetentionBackupListResultIterator) NotDone() bool { +func (iter LedgerDigestUploadsListResultIterator) 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 LongTermRetentionBackupListResultIterator) Response() LongTermRetentionBackupListResult { +func (iter LedgerDigestUploadsListResultIterator) Response() LedgerDigestUploadsListResult { 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 LongTermRetentionBackupListResultIterator) Value() LongTermRetentionBackup { +func (iter LedgerDigestUploadsListResultIterator) Value() LedgerDigestUploads { if !iter.page.NotDone() { - return LongTermRetentionBackup{} + return LedgerDigestUploads{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the LongTermRetentionBackupListResultIterator type. -func NewLongTermRetentionBackupListResultIterator(page LongTermRetentionBackupListResultPage) LongTermRetentionBackupListResultIterator { - return LongTermRetentionBackupListResultIterator{page: page} +// Creates a new instance of the LedgerDigestUploadsListResultIterator type. +func NewLedgerDigestUploadsListResultIterator(page LedgerDigestUploadsListResultPage) LedgerDigestUploadsListResultIterator { + return LedgerDigestUploadsListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (ltrblr LongTermRetentionBackupListResult) IsEmpty() bool { - return ltrblr.Value == nil || len(*ltrblr.Value) == 0 +func (ldulr LedgerDigestUploadsListResult) IsEmpty() bool { + return ldulr.Value == nil || len(*ldulr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (ltrblr LongTermRetentionBackupListResult) hasNextLink() bool { - return ltrblr.NextLink != nil && len(*ltrblr.NextLink) != 0 +func (ldulr LedgerDigestUploadsListResult) hasNextLink() bool { + return ldulr.NextLink != nil && len(*ldulr.NextLink) != 0 } -// longTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// ledgerDigestUploadsListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (ltrblr LongTermRetentionBackupListResult) longTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ltrblr.hasNextLink() { +func (ldulr LedgerDigestUploadsListResult) ledgerDigestUploadsListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ldulr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(ltrblr.NextLink))) + autorest.WithBaseURL(to.String(ldulr.NextLink))) } -// LongTermRetentionBackupListResultPage contains a page of LongTermRetentionBackup values. -type LongTermRetentionBackupListResultPage struct { - fn func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error) - ltrblr LongTermRetentionBackupListResult +// LedgerDigestUploadsListResultPage contains a page of LedgerDigestUploads values. +type LedgerDigestUploadsListResultPage struct { + fn func(context.Context, LedgerDigestUploadsListResult) (LedgerDigestUploadsListResult, error) + ldulr LedgerDigestUploadsListResult } // NextWithContext 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 *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *LedgerDigestUploadsListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -12828,11 +13878,11 @@ func (page *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.C }() } for { - next, err := page.fn(ctx, page.ltrblr) + next, err := page.fn(ctx, page.ldulr) if err != nil { return err } - page.ltrblr = next + page.ldulr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -12843,75 +13893,147 @@ func (page *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.C // 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. // Deprecated: Use NextWithContext() instead. -func (page *LongTermRetentionBackupListResultPage) Next() error { +func (page *LedgerDigestUploadsListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page LongTermRetentionBackupListResultPage) NotDone() bool { - return !page.ltrblr.IsEmpty() +func (page LedgerDigestUploadsListResultPage) NotDone() bool { + return !page.ldulr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page LongTermRetentionBackupListResultPage) Response() LongTermRetentionBackupListResult { - return page.ltrblr +func (page LedgerDigestUploadsListResultPage) Response() LedgerDigestUploadsListResult { + return page.ldulr } // Values returns the slice of values for the current page or nil if there are no values. -func (page LongTermRetentionBackupListResultPage) Values() []LongTermRetentionBackup { - if page.ltrblr.IsEmpty() { +func (page LedgerDigestUploadsListResultPage) Values() []LedgerDigestUploads { + if page.ldulr.IsEmpty() { return nil } - return *page.ltrblr.Value + return *page.ldulr.Value } -// Creates a new instance of the LongTermRetentionBackupListResultPage type. -func NewLongTermRetentionBackupListResultPage(cur LongTermRetentionBackupListResult, getNextPage func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error)) LongTermRetentionBackupListResultPage { - return LongTermRetentionBackupListResultPage{ - fn: getNextPage, - ltrblr: cur, +// Creates a new instance of the LedgerDigestUploadsListResultPage type. +func NewLedgerDigestUploadsListResultPage(cur LedgerDigestUploadsListResult, getNextPage func(context.Context, LedgerDigestUploadsListResult) (LedgerDigestUploadsListResult, error)) LedgerDigestUploadsListResultPage { + return LedgerDigestUploadsListResultPage{ + fn: getNextPage, + ldulr: cur, } } -// LongTermRetentionBackupOperationResult a LongTermRetentionBackup operation result resource. -type LongTermRetentionBackupOperationResult struct { - autorest.Response `json:"-"` - // LongTermRetentionOperationResultProperties - Resource properties. - *LongTermRetentionOperationResultProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// LedgerDigestUploadsProperties the properties of a database ledger digest upload settings. +type LedgerDigestUploadsProperties struct { + // DigestStorageEndpoint - The digest storage endpoint, which must be either an Azure blob storage endpoint or an URI for Azure Confidential Ledger. + DigestStorageEndpoint *string `json:"digestStorageEndpoint,omitempty"` + // State - READ-ONLY; Specifies the state of ledger digest upload. Possible values include: 'LedgerDigestUploadsStateEnabled', 'LedgerDigestUploadsStateDisabled' + State LedgerDigestUploadsState `json:"state,omitempty"` } -// MarshalJSON is the custom marshaler for LongTermRetentionBackupOperationResult. -func (ltrbor LongTermRetentionBackupOperationResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LedgerDigestUploadsProperties. +func (ldup LedgerDigestUploadsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ltrbor.LongTermRetentionOperationResultProperties != nil { - objectMap["properties"] = ltrbor.LongTermRetentionOperationResultProperties + if ldup.DigestStorageEndpoint != nil { + objectMap["digestStorageEndpoint"] = ldup.DigestStorageEndpoint } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackupOperationResult struct. -func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var longTermRetentionOperationResultProperties LongTermRetentionOperationResultProperties - err = json.Unmarshal(*v, &longTermRetentionOperationResultProperties) - if err != nil { - return err +// LicenseTypeCapability the license type capability +type LicenseTypeCapability struct { + // Name - READ-ONLY; License type identifier. + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LicenseTypeCapability. +func (ltc LicenseTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltc.Reason != nil { + objectMap["reason"] = ltc.Reason + } + return json.Marshal(objectMap) +} + +// ListAdvisor ... +type ListAdvisor struct { + autorest.Response `json:"-"` + Value *[]Advisor `json:"value,omitempty"` +} + +// ListRecommendedAction ... +type ListRecommendedAction struct { + autorest.Response `json:"-"` + Value *[]RecommendedAction `json:"value,omitempty"` +} + +// LocationCapabilities the location capability. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedManagedInstanceVersions - READ-ONLY; The list of supported managed instance versions. + SupportedManagedInstanceVersions *[]ManagedInstanceVersionCapability `json:"supportedManagedInstanceVersions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationCapabilities. +func (lc LocationCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lc.Reason != nil { + objectMap["reason"] = lc.Reason + } + return json.Marshal(objectMap) +} + +// LogicalDatabaseTransparentDataEncryption a logical database transparent data encryption state. +type LogicalDatabaseTransparentDataEncryption struct { + autorest.Response `json:"-"` + // TransparentDataEncryptionProperties - Resource properties. + *TransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogicalDatabaseTransparentDataEncryption. +func (ldtde LogicalDatabaseTransparentDataEncryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ldtde.TransparentDataEncryptionProperties != nil { + objectMap["properties"] = ldtde.TransparentDataEncryptionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogicalDatabaseTransparentDataEncryption struct. +func (ldtde *LogicalDatabaseTransparentDataEncryption) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var transparentDataEncryptionProperties TransparentDataEncryptionProperties + err = json.Unmarshal(*v, &transparentDataEncryptionProperties) + if err != nil { + return err } - ltrbor.LongTermRetentionOperationResultProperties = &longTermRetentionOperationResultProperties + ldtde.TransparentDataEncryptionProperties = &transparentDataEncryptionProperties } case "id": if v != nil { @@ -12920,7 +14042,7 @@ func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) if err != nil { return err } - ltrbor.ID = &ID + ldtde.ID = &ID } case "name": if v != nil { @@ -12929,7 +14051,7 @@ func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) if err != nil { return err } - ltrbor.Name = &name + ldtde.Name = &name } case "type": if v != nil { @@ -12938,7 +14060,7 @@ func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) if err != nil { return err } - ltrbor.Type = &typeVar + ldtde.Type = &typeVar } } } @@ -12946,523 +14068,368 @@ func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) return nil } -// LongTermRetentionBackupProperties properties of a long term retention backup -type LongTermRetentionBackupProperties struct { - // ServerName - READ-ONLY; The server name that the backup database belong to. - ServerName *string `json:"serverName,omitempty"` - // ServerCreateTime - READ-ONLY; The create time of the server. - ServerCreateTime *date.Time `json:"serverCreateTime,omitempty"` - // DatabaseName - READ-ONLY; The name of the database the backup belong to - DatabaseName *string `json:"databaseName,omitempty"` - // DatabaseDeletionTime - READ-ONLY; The delete time of the database - DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` - // BackupTime - READ-ONLY; The time the backup was taken - BackupTime *date.Time `json:"backupTime,omitempty"` - // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. - BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` - // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' - BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` - // RequestedBackupStorageRedundancy - The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' - RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` +// LogicalDatabaseTransparentDataEncryptionListResult a list of transparent data encryptions +type LogicalDatabaseTransparentDataEncryptionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LogicalDatabaseTransparentDataEncryption `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for LongTermRetentionBackupProperties. -func (ltrbp LongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LogicalDatabaseTransparentDataEncryptionListResult. +func (ldtdelr LogicalDatabaseTransparentDataEncryptionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ltrbp.RequestedBackupStorageRedundancy != "" { - objectMap["requestedBackupStorageRedundancy"] = ltrbp.RequestedBackupStorageRedundancy - } return json.Marshal(objectMap) } -// LongTermRetentionBackupsCopyByResourceGroupFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type LongTermRetentionBackupsCopyByResourceGroupFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +// LogicalDatabaseTransparentDataEncryptionListResultIterator provides access to a complete listing of +// LogicalDatabaseTransparentDataEncryption values. +type LogicalDatabaseTransparentDataEncryptionListResultIterator struct { + i int + page LogicalDatabaseTransparentDataEncryptionListResultPage } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { +// NextWithContext 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 *LogicalDatabaseTransparentDataEncryptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalDatabaseTransparentDataEncryptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- return err } - future.FutureAPI = &azFuture - future.Result = future.result + iter.i = 0 return nil } -// result is the default implementation for LongTermRetentionBackupsCopyByResourceGroupFuture.Result. -func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ltrbor.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyByResourceGroupFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { - ltrbor, err = client.CopyByResourceGroupResponder(ltrbor.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") - } - } - return +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LogicalDatabaseTransparentDataEncryptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) } -// LongTermRetentionBackupsCopyFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type LongTermRetentionBackupsCopyFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LogicalDatabaseTransparentDataEncryptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsCopyFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// Response returns the raw server response from the last page request. +func (iter LogicalDatabaseTransparentDataEncryptionListResultIterator) Response() LogicalDatabaseTransparentDataEncryptionListResult { + return iter.page.Response() } -// result is the default implementation for LongTermRetentionBackupsCopyFuture.Result. -func (future *LongTermRetentionBackupsCopyFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ltrbor.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { - ltrbor, err = client.CopyResponder(ltrbor.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", ltrbor.Response.Response, "Failure responding to request") - } +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LogicalDatabaseTransparentDataEncryptionListResultIterator) Value() LogicalDatabaseTransparentDataEncryption { + if !iter.page.NotDone() { + return LogicalDatabaseTransparentDataEncryption{} } - return + return iter.page.Values()[iter.i] } -// LongTermRetentionBackupsDeleteByResourceGroupFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type LongTermRetentionBackupsDeleteByResourceGroupFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +// Creates a new instance of the LogicalDatabaseTransparentDataEncryptionListResultIterator type. +func NewLogicalDatabaseTransparentDataEncryptionListResultIterator(page LogicalDatabaseTransparentDataEncryptionListResultPage) LogicalDatabaseTransparentDataEncryptionListResultIterator { + return LogicalDatabaseTransparentDataEncryptionListResultIterator{page: page} } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// IsEmpty returns true if the ListResult contains no values. +func (ldtdelr LogicalDatabaseTransparentDataEncryptionListResult) IsEmpty() bool { + return ldtdelr.Value == nil || len(*ldtdelr.Value) == 0 } -// result is the default implementation for LongTermRetentionBackupsDeleteByResourceGroupFuture.Result. -func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteByResourceGroupFuture") - return +// hasNextLink returns true if the NextLink is not empty. +func (ldtdelr LogicalDatabaseTransparentDataEncryptionListResult) hasNextLink() bool { + return ldtdelr.NextLink != nil && len(*ldtdelr.NextLink) != 0 +} + +// logicalDatabaseTransparentDataEncryptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ldtdelr LogicalDatabaseTransparentDataEncryptionListResult) logicalDatabaseTransparentDataEncryptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ldtdelr.hasNextLink() { + return nil, nil } - ar.Response = future.Response() - return + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ldtdelr.NextLink))) } -// LongTermRetentionBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type LongTermRetentionBackupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +// LogicalDatabaseTransparentDataEncryptionListResultPage contains a page of +// LogicalDatabaseTransparentDataEncryption values. +type LogicalDatabaseTransparentDataEncryptionListResultPage struct { + fn func(context.Context, LogicalDatabaseTransparentDataEncryptionListResult) (LogicalDatabaseTransparentDataEncryptionListResult, error) + ldtdelr LogicalDatabaseTransparentDataEncryptionListResult } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// NextWithContext 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 *LogicalDatabaseTransparentDataEncryptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalDatabaseTransparentDataEncryptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ldtdelr) + if err != nil { + return err + } + page.ldtdelr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - future.FutureAPI = &azFuture - future.Result = future.result return nil } -// result is the default implementation for LongTermRetentionBackupsDeleteFuture.Result. -func (future *LongTermRetentionBackupsDeleteFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteFuture") - return - } - ar.Response = future.Response() - return +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *LogicalDatabaseTransparentDataEncryptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) } -// LongTermRetentionBackupsUpdateByResourceGroupFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type LongTermRetentionBackupsUpdateByResourceGroupFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LogicalDatabaseTransparentDataEncryptionListResultPage) NotDone() bool { + return !page.ldtdelr.IsEmpty() } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// Response returns the raw server response from the last page request. +func (page LogicalDatabaseTransparentDataEncryptionListResultPage) Response() LogicalDatabaseTransparentDataEncryptionListResult { + return page.ldtdelr } -// result is the default implementation for LongTermRetentionBackupsUpdateByResourceGroupFuture.Result. -func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ltrbor.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateByResourceGroupFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { - ltrbor, err = client.UpdateByResourceGroupResponder(ltrbor.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") - } +// Values returns the slice of values for the current page or nil if there are no values. +func (page LogicalDatabaseTransparentDataEncryptionListResultPage) Values() []LogicalDatabaseTransparentDataEncryption { + if page.ldtdelr.IsEmpty() { + return nil } - return + return *page.ldtdelr.Value } -// LongTermRetentionBackupsUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type LongTermRetentionBackupsUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +// Creates a new instance of the LogicalDatabaseTransparentDataEncryptionListResultPage type. +func NewLogicalDatabaseTransparentDataEncryptionListResultPage(cur LogicalDatabaseTransparentDataEncryptionListResult, getNextPage func(context.Context, LogicalDatabaseTransparentDataEncryptionListResult) (LogicalDatabaseTransparentDataEncryptionListResult, error)) LogicalDatabaseTransparentDataEncryptionListResultPage { + return LogicalDatabaseTransparentDataEncryptionListResultPage{ + fn: getNextPage, + ldtdelr: cur, + } } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionBackupsUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// LogicalServerAdvancedThreatProtectionListResult a list of the server's Advanced Threat Protection +// configurations. +type LogicalServerAdvancedThreatProtectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerAdvancedThreatProtection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// result is the default implementation for LongTermRetentionBackupsUpdateFuture.Result. -func (future *LongTermRetentionBackupsUpdateFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ltrbor.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { - ltrbor, err = client.UpdateResponder(ltrbor.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", ltrbor.Response.Response, "Failure responding to request") - } - } - return +// MarshalJSON is the custom marshaler for LogicalServerAdvancedThreatProtectionListResult. +func (lsatplr LogicalServerAdvancedThreatProtectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) } -// LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +// LogicalServerAdvancedThreatProtectionListResultIterator provides access to a complete listing of +// ServerAdvancedThreatProtection values. +type LogicalServerAdvancedThreatProtectionListResultIterator struct { + i int + page LogicalServerAdvancedThreatProtectionListResultPage } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { +// NextWithContext 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 *LogicalServerAdvancedThreatProtectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerAdvancedThreatProtectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- return err } - future.FutureAPI = &azFuture - future.Result = future.result + iter.i = 0 return nil } -// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture.Result. -func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture") - return - } - ar.Response = future.Response() - return +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LogicalServerAdvancedThreatProtectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) } -// LongTermRetentionManagedInstanceBackupsDeleteFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type LongTermRetentionManagedInstanceBackupsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LogicalServerAdvancedThreatProtectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// Response returns the raw server response from the last page request. +func (iter LogicalServerAdvancedThreatProtectionListResultIterator) Response() LogicalServerAdvancedThreatProtectionListResult { + return iter.page.Response() } -// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteFuture.Result. -func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteFuture") - return +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LogicalServerAdvancedThreatProtectionListResultIterator) Value() ServerAdvancedThreatProtection { + if !iter.page.NotDone() { + return ServerAdvancedThreatProtection{} } - ar.Response = future.Response() - return + return iter.page.Values()[iter.i] } -// LongTermRetentionOperationResultProperties contains the operation result properties for long term -// retention backup operation. -type LongTermRetentionOperationResultProperties struct { - // RequestID - READ-ONLY; Request Id. - RequestID *uuid.UUID `json:"requestId,omitempty"` - // OperationType - READ-ONLY; Operation type. - OperationType *string `json:"operationType,omitempty"` - // FromBackupResourceID - READ-ONLY; Source backup resource id - FromBackupResourceID *string `json:"fromBackupResourceId,omitempty"` - // ToBackupResourceID - READ-ONLY; Target backup resource id - ToBackupResourceID *string `json:"toBackupResourceId,omitempty"` - // TargetBackupStorageRedundancy - READ-ONLY; The storage redundancy type of the copied backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' - TargetBackupStorageRedundancy BackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` - // Status - READ-ONLY; Operation status - Status *string `json:"status,omitempty"` - // Message - READ-ONLY; Progress message - Message *string `json:"message,omitempty"` +// Creates a new instance of the LogicalServerAdvancedThreatProtectionListResultIterator type. +func NewLogicalServerAdvancedThreatProtectionListResultIterator(page LogicalServerAdvancedThreatProtectionListResultPage) LogicalServerAdvancedThreatProtectionListResultIterator { + return LogicalServerAdvancedThreatProtectionListResultIterator{page: page} } -// MarshalJSON is the custom marshaler for LongTermRetentionOperationResultProperties. -func (ltrorp LongTermRetentionOperationResultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// IsEmpty returns true if the ListResult contains no values. +func (lsatplr LogicalServerAdvancedThreatProtectionListResult) IsEmpty() bool { + return lsatplr.Value == nil || len(*lsatplr.Value) == 0 } -// LongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type LongTermRetentionPoliciesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(LongTermRetentionPoliciesClient) (LongTermRetentionPolicy, error) +// hasNextLink returns true if the NextLink is not empty. +func (lsatplr LogicalServerAdvancedThreatProtectionListResult) hasNextLink() bool { + return lsatplr.NextLink != nil && len(*lsatplr.NextLink) != 0 } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// logicalServerAdvancedThreatProtectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lsatplr LogicalServerAdvancedThreatProtectionListResult) logicalServerAdvancedThreatProtectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !lsatplr.hasNextLink() { + return nil, nil } - future.FutureAPI = &azFuture - future.Result = future.result - return nil + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lsatplr.NextLink))) } -// result is the default implementation for LongTermRetentionPoliciesCreateOrUpdateFuture.Result. -func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) result(client LongTermRetentionPoliciesClient) (ltrp LongTermRetentionPolicy, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ltrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionPoliciesCreateOrUpdateFuture") - return +// LogicalServerAdvancedThreatProtectionListResultPage contains a page of ServerAdvancedThreatProtection +// values. +type LogicalServerAdvancedThreatProtectionListResultPage struct { + fn func(context.Context, LogicalServerAdvancedThreatProtectionListResult) (LogicalServerAdvancedThreatProtectionListResult, error) + lsatplr LogicalServerAdvancedThreatProtectionListResult +} + +// NextWithContext 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 *LogicalServerAdvancedThreatProtectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerAdvancedThreatProtectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ltrp.Response.Response, err = future.GetResult(sender); err == nil && ltrp.Response.Response.StatusCode != http.StatusNoContent { - ltrp, err = client.CreateOrUpdateResponder(ltrp.Response.Response) + for { + next, err := page.fn(ctx, page.lsatplr) if err != nil { - err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", ltrp.Response.Response, "Failure responding to request") + return err + } + page.lsatplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break } } - return + return nil } -// LongTermRetentionPolicy a long term retention policy. -type LongTermRetentionPolicy struct { - autorest.Response `json:"-"` - // BaseLongTermRetentionPolicyProperties - Resource properties. - *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *LogicalServerAdvancedThreatProtectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) } -// MarshalJSON is the custom marshaler for LongTermRetentionPolicy. -func (ltrp LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ltrp.BaseLongTermRetentionPolicyProperties != nil { - objectMap["properties"] = ltrp.BaseLongTermRetentionPolicyProperties - } - return json.Marshal(objectMap) +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LogicalServerAdvancedThreatProtectionListResultPage) NotDone() bool { + return !page.lsatplr.IsEmpty() } -// UnmarshalJSON is the custom unmarshaler for LongTermRetentionPolicy struct. -func (ltrp *LongTermRetentionPolicy) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties - err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) - if err != nil { - return err - } - ltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ltrp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ltrp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ltrp.Type = &typeVar - } - } +// Response returns the raw server response from the last page request. +func (page LogicalServerAdvancedThreatProtectionListResultPage) Response() LogicalServerAdvancedThreatProtectionListResult { + return page.lsatplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LogicalServerAdvancedThreatProtectionListResultPage) Values() []ServerAdvancedThreatProtection { + if page.lsatplr.IsEmpty() { + return nil } + return *page.lsatplr.Value +} - return nil +// Creates a new instance of the LogicalServerAdvancedThreatProtectionListResultPage type. +func NewLogicalServerAdvancedThreatProtectionListResultPage(cur LogicalServerAdvancedThreatProtectionListResult, getNextPage func(context.Context, LogicalServerAdvancedThreatProtectionListResult) (LogicalServerAdvancedThreatProtectionListResult, error)) LogicalServerAdvancedThreatProtectionListResultPage { + return LogicalServerAdvancedThreatProtectionListResultPage{ + fn: getNextPage, + lsatplr: cur, + } } -// LongTermRetentionPolicyListResult a list of long term retention policies. -type LongTermRetentionPolicyListResult struct { +// LogicalServerSecurityAlertPolicyListResult a list of the server's security alert policies. +type LogicalServerSecurityAlertPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]LongTermRetentionPolicy `json:"value,omitempty"` + Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for LongTermRetentionPolicyListResult. -func (ltrplr LongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LogicalServerSecurityAlertPolicyListResult. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// LongTermRetentionPolicyListResultIterator provides access to a complete listing of -// LongTermRetentionPolicy values. -type LongTermRetentionPolicyListResultIterator struct { +// LogicalServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ServerSecurityAlertPolicy values. +type LogicalServerSecurityAlertPolicyListResultIterator struct { i int - page LongTermRetentionPolicyListResultPage + page LogicalServerSecurityAlertPolicyListResultPage } // NextWithContext 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 *LongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *LogicalServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -13487,67 +14454,67 @@ func (iter *LongTermRetentionPolicyListResultIterator) NextWithContext(ctx conte // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *LongTermRetentionPolicyListResultIterator) Next() error { +func (iter *LogicalServerSecurityAlertPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter LongTermRetentionPolicyListResultIterator) NotDone() bool { +func (iter LogicalServerSecurityAlertPolicyListResultIterator) 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 LongTermRetentionPolicyListResultIterator) Response() LongTermRetentionPolicyListResult { +func (iter LogicalServerSecurityAlertPolicyListResultIterator) Response() LogicalServerSecurityAlertPolicyListResult { 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 LongTermRetentionPolicyListResultIterator) Value() LongTermRetentionPolicy { +func (iter LogicalServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { if !iter.page.NotDone() { - return LongTermRetentionPolicy{} + return ServerSecurityAlertPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the LongTermRetentionPolicyListResultIterator type. -func NewLongTermRetentionPolicyListResultIterator(page LongTermRetentionPolicyListResultPage) LongTermRetentionPolicyListResultIterator { - return LongTermRetentionPolicyListResultIterator{page: page} +// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultIterator type. +func NewLogicalServerSecurityAlertPolicyListResultIterator(page LogicalServerSecurityAlertPolicyListResultPage) LogicalServerSecurityAlertPolicyListResultIterator { + return LogicalServerSecurityAlertPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (ltrplr LongTermRetentionPolicyListResult) IsEmpty() bool { - return ltrplr.Value == nil || len(*ltrplr.Value) == 0 +func (lssaplr LogicalServerSecurityAlertPolicyListResult) IsEmpty() bool { + return lssaplr.Value == nil || len(*lssaplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (ltrplr LongTermRetentionPolicyListResult) hasNextLink() bool { - return ltrplr.NextLink != nil && len(*ltrplr.NextLink) != 0 +func (lssaplr LogicalServerSecurityAlertPolicyListResult) hasNextLink() bool { + return lssaplr.NextLink != nil && len(*lssaplr.NextLink) != 0 } -// longTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// logicalServerSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (ltrplr LongTermRetentionPolicyListResult) longTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ltrplr.hasNextLink() { +func (lssaplr LogicalServerSecurityAlertPolicyListResult) logicalServerSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !lssaplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(ltrplr.NextLink))) + autorest.WithBaseURL(to.String(lssaplr.NextLink))) } -// LongTermRetentionPolicyListResultPage contains a page of LongTermRetentionPolicy values. -type LongTermRetentionPolicyListResultPage struct { - fn func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error) - ltrplr LongTermRetentionPolicyListResult +// LogicalServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. +type LogicalServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error) + lssaplr LogicalServerSecurityAlertPolicyListResult } // NextWithContext 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 *LongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *LogicalServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -13557,11 +14524,11 @@ func (page *LongTermRetentionPolicyListResultPage) NextWithContext(ctx context.C }() } for { - next, err := page.fn(ctx, page.ltrplr) + next, err := page.fn(ctx, page.lssaplr) if err != nil { return err } - page.ltrplr = next + page.lssaplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -13572,62 +14539,55 @@ func (page *LongTermRetentionPolicyListResultPage) NextWithContext(ctx context.C // 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. // Deprecated: Use NextWithContext() instead. -func (page *LongTermRetentionPolicyListResultPage) Next() error { +func (page *LogicalServerSecurityAlertPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page LongTermRetentionPolicyListResultPage) NotDone() bool { - return !page.ltrplr.IsEmpty() +func (page LogicalServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.lssaplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page LongTermRetentionPolicyListResultPage) Response() LongTermRetentionPolicyListResult { - return page.ltrplr +func (page LogicalServerSecurityAlertPolicyListResultPage) Response() LogicalServerSecurityAlertPolicyListResult { + return page.lssaplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page LongTermRetentionPolicyListResultPage) Values() []LongTermRetentionPolicy { - if page.ltrplr.IsEmpty() { +func (page LogicalServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { + if page.lssaplr.IsEmpty() { return nil } - return *page.ltrplr.Value + return *page.lssaplr.Value } -// Creates a new instance of the LongTermRetentionPolicyListResultPage type. -func NewLongTermRetentionPolicyListResultPage(cur LongTermRetentionPolicyListResult, getNextPage func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error)) LongTermRetentionPolicyListResultPage { - return LongTermRetentionPolicyListResultPage{ - fn: getNextPage, - ltrplr: cur, +// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultPage type. +func NewLogicalServerSecurityAlertPolicyListResultPage(cur LogicalServerSecurityAlertPolicyListResult, getNextPage func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error)) LogicalServerSecurityAlertPolicyListResultPage { + return LogicalServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + lssaplr: cur, } } -// MaintenanceConfigurationCapability the maintenance configuration capability -type MaintenanceConfigurationCapability struct { - // Name - READ-ONLY; Maintenance configuration name - Name *string `json:"name,omitempty"` - // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the maintenance configuration. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` +// LogSizeCapability the log size capability. +type LogSizeCapability struct { + // Limit - READ-ONLY; The log size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'LogSizeUnitMegabytes', 'LogSizeUnitGigabytes', 'LogSizeUnitTerabytes', 'LogSizeUnitPetabytes', 'LogSizeUnitPercent' + Unit LogSizeUnit `json:"unit,omitempty"` } -// MarshalJSON is the custom marshaler for MaintenanceConfigurationCapability. -func (mcc MaintenanceConfigurationCapability) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LogSizeCapability. +func (lsc LogSizeCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mcc.Reason != nil { - objectMap["reason"] = mcc.Reason - } return json.Marshal(objectMap) } -// MaintenanceWindowOptions maintenance window options. -type MaintenanceWindowOptions struct { +// LongTermRetentionBackup a long term retention backup. +type LongTermRetentionBackup struct { autorest.Response `json:"-"` - // MaintenanceWindowOptionsProperties - Resource properties. - *MaintenanceWindowOptionsProperties `json:"properties,omitempty"` + // LongTermRetentionBackupProperties - Resource properties. + *LongTermRetentionBackupProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -13636,17 +14596,17 @@ type MaintenanceWindowOptions struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for MaintenanceWindowOptions. -func (mwo MaintenanceWindowOptions) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LongTermRetentionBackup. +func (ltrb LongTermRetentionBackup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mwo.MaintenanceWindowOptionsProperties != nil { - objectMap["properties"] = mwo.MaintenanceWindowOptionsProperties + if ltrb.LongTermRetentionBackupProperties != nil { + objectMap["properties"] = ltrb.LongTermRetentionBackupProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for MaintenanceWindowOptions struct. -func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackup struct. +func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -13656,12 +14616,12 @@ func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var maintenanceWindowOptionsProperties MaintenanceWindowOptionsProperties - err = json.Unmarshal(*v, &maintenanceWindowOptionsProperties) + var longTermRetentionBackupProperties LongTermRetentionBackupProperties + err = json.Unmarshal(*v, &longTermRetentionBackupProperties) if err != nil { return err } - mwo.MaintenanceWindowOptionsProperties = &maintenanceWindowOptionsProperties + ltrb.LongTermRetentionBackupProperties = &longTermRetentionBackupProperties } case "id": if v != nil { @@ -13670,7 +14630,7 @@ func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { if err != nil { return err } - mwo.ID = &ID + ltrb.ID = &ID } case "name": if v != nil { @@ -13679,7 +14639,7 @@ func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { if err != nil { return err } - mwo.Name = &name + ltrb.Name = &name } case "type": if v != nil { @@ -13688,7 +14648,7 @@ func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { if err != nil { return err } - mwo.Type = &typeVar + ltrb.Type = &typeVar } } } @@ -13696,29 +14656,177 @@ func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { return nil } -// MaintenanceWindowOptionsProperties maintenance window options properties. -type MaintenanceWindowOptionsProperties struct { - // IsEnabled - Whether maintenance windows are enabled for the database. - IsEnabled *bool `json:"isEnabled,omitempty"` - // MaintenanceWindowCycles - Available maintenance cycles e.g. {Saturday, 0, 48*60}, {Wednesday, 0, 24*60}. - MaintenanceWindowCycles *[]MaintenanceWindowTimeRange `json:"maintenanceWindowCycles,omitempty"` - // MinDurationInMinutes - Minimum duration of maintenance window. - MinDurationInMinutes *int32 `json:"minDurationInMinutes,omitempty"` - // DefaultDurationInMinutes - Default duration for maintenance window. - DefaultDurationInMinutes *int32 `json:"defaultDurationInMinutes,omitempty"` - // MinCycles - Minimum number of maintenance windows cycles to be set on the database. - MinCycles *int32 `json:"minCycles,omitempty"` - // TimeGranularityInMinutes - Time granularity in minutes for maintenance windows. - TimeGranularityInMinutes *int32 `json:"timeGranularityInMinutes,omitempty"` - // AllowMultipleMaintenanceWindowsPerCycle - Whether we allow multiple maintenance windows per cycle. - AllowMultipleMaintenanceWindowsPerCycle *bool `json:"allowMultipleMaintenanceWindowsPerCycle,omitempty"` +// LongTermRetentionBackupListResult a list of long term retention backups. +type LongTermRetentionBackupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LongTermRetentionBackup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// MaintenanceWindows maintenance windows. -type MaintenanceWindows struct { +// MarshalJSON is the custom marshaler for LongTermRetentionBackupListResult. +func (ltrblr LongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupListResultIterator provides access to a complete listing of +// LongTermRetentionBackup values. +type LongTermRetentionBackupListResultIterator struct { + i int + page LongTermRetentionBackupListResultPage +} + +// NextWithContext 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 *LongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LongTermRetentionBackupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LongTermRetentionBackupListResultIterator) 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 LongTermRetentionBackupListResultIterator) Response() LongTermRetentionBackupListResult { + 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 LongTermRetentionBackupListResultIterator) Value() LongTermRetentionBackup { + if !iter.page.NotDone() { + return LongTermRetentionBackup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LongTermRetentionBackupListResultIterator type. +func NewLongTermRetentionBackupListResultIterator(page LongTermRetentionBackupListResultPage) LongTermRetentionBackupListResultIterator { + return LongTermRetentionBackupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ltrblr LongTermRetentionBackupListResult) IsEmpty() bool { + return ltrblr.Value == nil || len(*ltrblr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ltrblr LongTermRetentionBackupListResult) hasNextLink() bool { + return ltrblr.NextLink != nil && len(*ltrblr.NextLink) != 0 +} + +// longTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ltrblr LongTermRetentionBackupListResult) longTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrblr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ltrblr.NextLink))) +} + +// LongTermRetentionBackupListResultPage contains a page of LongTermRetentionBackup values. +type LongTermRetentionBackupListResultPage struct { + fn func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error) + ltrblr LongTermRetentionBackupListResult +} + +// NextWithContext 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 *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ltrblr) + if err != nil { + return err + } + page.ltrblr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *LongTermRetentionBackupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LongTermRetentionBackupListResultPage) NotDone() bool { + return !page.ltrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LongTermRetentionBackupListResultPage) Response() LongTermRetentionBackupListResult { + return page.ltrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LongTermRetentionBackupListResultPage) Values() []LongTermRetentionBackup { + if page.ltrblr.IsEmpty() { + return nil + } + return *page.ltrblr.Value +} + +// Creates a new instance of the LongTermRetentionBackupListResultPage type. +func NewLongTermRetentionBackupListResultPage(cur LongTermRetentionBackupListResult, getNextPage func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error)) LongTermRetentionBackupListResultPage { + return LongTermRetentionBackupListResultPage{ + fn: getNextPage, + ltrblr: cur, + } +} + +// LongTermRetentionBackupOperationResult a LongTermRetentionBackup operation result resource. +type LongTermRetentionBackupOperationResult struct { autorest.Response `json:"-"` - // MaintenanceWindowsProperties - Resource properties. - *MaintenanceWindowsProperties `json:"properties,omitempty"` + // LongTermRetentionOperationResultProperties - Resource properties. + *LongTermRetentionOperationResultProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -13727,17 +14835,17 @@ type MaintenanceWindows struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for MaintenanceWindows. -func (mw MaintenanceWindows) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LongTermRetentionBackupOperationResult. +func (ltrbor LongTermRetentionBackupOperationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mw.MaintenanceWindowsProperties != nil { - objectMap["properties"] = mw.MaintenanceWindowsProperties + if ltrbor.LongTermRetentionOperationResultProperties != nil { + objectMap["properties"] = ltrbor.LongTermRetentionOperationResultProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for MaintenanceWindows struct. -func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackupOperationResult struct. +func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -13747,12 +14855,12 @@ func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var maintenanceWindowsProperties MaintenanceWindowsProperties - err = json.Unmarshal(*v, &maintenanceWindowsProperties) + var longTermRetentionOperationResultProperties LongTermRetentionOperationResultProperties + err = json.Unmarshal(*v, &longTermRetentionOperationResultProperties) if err != nil { return err } - mw.MaintenanceWindowsProperties = &maintenanceWindowsProperties + ltrbor.LongTermRetentionOperationResultProperties = &longTermRetentionOperationResultProperties } case "id": if v != nil { @@ -13761,7 +14869,7 @@ func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { if err != nil { return err } - mw.ID = &ID + ltrbor.ID = &ID } case "name": if v != nil { @@ -13770,7 +14878,7 @@ func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { if err != nil { return err } - mw.Name = &name + ltrbor.Name = &name } case "type": if v != nil { @@ -13779,7 +14887,7 @@ func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { if err != nil { return err } - mw.Type = &typeVar + ltrbor.Type = &typeVar } } } @@ -13787,32 +14895,46 @@ func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { return nil } -// MaintenanceWindowsProperties maintenance windows resource properties. -type MaintenanceWindowsProperties struct { - TimeRanges *[]MaintenanceWindowTimeRange `json:"timeRanges,omitempty"` +// LongTermRetentionBackupProperties properties of a long term retention backup +type LongTermRetentionBackupProperties struct { + // ServerName - READ-ONLY; The server name that the backup database belong to. + ServerName *string `json:"serverName,omitempty"` + // ServerCreateTime - READ-ONLY; The create time of the server. + ServerCreateTime *date.Time `json:"serverCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` } -// MaintenanceWindowTimeRange maintenance window time range. -type MaintenanceWindowTimeRange struct { - // DayOfWeek - Day of maintenance window. Possible values include: 'DayOfWeekSunday', 'DayOfWeekMonday', 'DayOfWeekTuesday', 'DayOfWeekWednesday', 'DayOfWeekThursday', 'DayOfWeekFriday', 'DayOfWeekSaturday' - DayOfWeek DayOfWeek `json:"dayOfWeek,omitempty"` - // StartTime - Start time minutes offset from 12am. - StartTime *string `json:"startTime,omitempty"` - // Duration - Duration of maintenance window in minutes. - Duration *string `json:"duration,omitempty"` +// MarshalJSON is the custom marshaler for LongTermRetentionBackupProperties. +func (ltrbp LongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrbp.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = ltrbp.RequestedBackupStorageRedundancy + } + return json.Marshal(objectMap) } -// ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { +// LongTermRetentionBackupsCopyByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsCopyByResourceGroupFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -13822,40 +14944,40 @@ func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) Unmar return nil } -// result is the default implementation for ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. -func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { +// result is the default implementation for LongTermRetentionBackupsCopyByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", future.Response(), "Polling failure") return } if !done { - mbstrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture") + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyByResourceGroupFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { - mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.CopyByResourceGroupResponder(ltrbor.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") } } return } -// ManagedBackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type ManagedBackupShortTermRetentionPoliciesUpdateFuture struct { +// LongTermRetentionBackupsCopyFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsCopyFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *LongTermRetentionBackupsCopyFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -13865,342 +14987,370 @@ func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON return nil } -// result is the default implementation for ManagedBackupShortTermRetentionPoliciesUpdateFuture.Result. -func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { +// result is the default implementation for LongTermRetentionBackupsCopyFuture.Result. +func (future *LongTermRetentionBackupsCopyFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", future.Response(), "Polling failure") return } if !done { - mbstrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture") + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { - mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.CopyResponder(ltrbor.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", ltrbor.Response.Response, "Failure responding to request") } } return } -// ManagedBackupShortTermRetentionPolicy a short term retention policy. -type ManagedBackupShortTermRetentionPolicy struct { - autorest.Response `json:"-"` - // ManagedBackupShortTermRetentionPolicyProperties - Resource properties. - *ManagedBackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// LongTermRetentionBackupsDeleteByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) } -// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicy. -func (mbstrp ManagedBackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mbstrp.ManagedBackupShortTermRetentionPolicyProperties != nil { - objectMap["properties"] = mbstrp.ManagedBackupShortTermRetentionPolicyProperties +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return json.Marshal(objectMap) + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// UnmarshalJSON is the custom unmarshaler for ManagedBackupShortTermRetentionPolicy struct. -func (mbstrp *ManagedBackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// result is the default implementation for LongTermRetentionBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) if err != nil { - return err + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var managedBackupShortTermRetentionPolicyProperties ManagedBackupShortTermRetentionPolicyProperties - err = json.Unmarshal(*v, &managedBackupShortTermRetentionPolicyProperties) - if err != nil { - return err - } - mbstrp.ManagedBackupShortTermRetentionPolicyProperties = &managedBackupShortTermRetentionPolicyProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mbstrp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mbstrp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mbstrp.Type = &typeVar - } - } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteByResourceGroupFuture") + return } - - return nil -} - -// ManagedBackupShortTermRetentionPolicyListResult a list of short term retention policies. -type ManagedBackupShortTermRetentionPolicyListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]ManagedBackupShortTermRetentionPolicy `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicyListResult. -func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) + ar.Response = future.Response() + return } -// ManagedBackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of -// ManagedBackupShortTermRetentionPolicy values. -type ManagedBackupShortTermRetentionPolicyListResultIterator struct { - i int - page ManagedBackupShortTermRetentionPolicyListResultPage +// LongTermRetentionBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) } -// NextWithContext 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 *ManagedBackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { return err } - iter.i = 0 + future.FutureAPI = &azFuture + future.Result = future.result return nil } -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ManagedBackupShortTermRetentionPolicyListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) +// result is the default implementation for LongTermRetentionBackupsDeleteFuture.Result. +func (future *LongTermRetentionBackupsDeleteFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return } -// Response returns the raw server response from the last page request. -func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) Response() ManagedBackupShortTermRetentionPolicyListResult { - return iter.page.Response() +// LongTermRetentionBackupsUpdateByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsUpdateByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) } -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) Value() ManagedBackupShortTermRetentionPolicy { - if !iter.page.NotDone() { - return ManagedBackupShortTermRetentionPolicy{} +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return iter.page.Values()[iter.i] + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultIterator type. -func NewManagedBackupShortTermRetentionPolicyListResultIterator(page ManagedBackupShortTermRetentionPolicyListResultPage) ManagedBackupShortTermRetentionPolicyListResultIterator { - return ManagedBackupShortTermRetentionPolicyListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) IsEmpty() bool { - return mbstrplr.Value == nil || len(*mbstrplr.Value) == 0 +// result is the default implementation for LongTermRetentionBackupsUpdateByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateByResourceGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.UpdateByResourceGroupResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return } -// hasNextLink returns true if the NextLink is not empty. -func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) hasNextLink() bool { - return mbstrplr.NextLink != nil && len(*mbstrplr.NextLink) != 0 +// LongTermRetentionBackupsUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) } -// managedBackupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) managedBackupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mbstrplr.hasNextLink() { - return nil, nil +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(mbstrplr.NextLink))) -} - -// ManagedBackupShortTermRetentionPolicyListResultPage contains a page of -// ManagedBackupShortTermRetentionPolicy values. -type ManagedBackupShortTermRetentionPolicyListResultPage struct { - fn func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error) - mbstrplr ManagedBackupShortTermRetentionPolicyListResult + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// NextWithContext 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 *ManagedBackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() +// result is the default implementation for LongTermRetentionBackupsUpdateFuture.Result. +func (future *LongTermRetentionBackupsUpdateFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", future.Response(), "Polling failure") + return } - for { - next, err := page.fn(ctx, page.mbstrplr) + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.UpdateResponder(ltrbor.Response.Response) if err != nil { - return err - } - page.mbstrplr = next - if !next.hasNextLink() || !next.IsEmpty() { - break + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", ltrbor.Response.Response, "Failure responding to request") } } - return nil + return } -// 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. -// Deprecated: Use NextWithContext() instead. -func (page *ManagedBackupShortTermRetentionPolicyListResultPage) Next() error { - return page.NextWithContext(context.Background()) +// LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) } -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedBackupShortTermRetentionPolicyListResultPage) NotDone() bool { - return !page.mbstrplr.IsEmpty() +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// Response returns the raw server response from the last page request. -func (page ManagedBackupShortTermRetentionPolicyListResultPage) Response() ManagedBackupShortTermRetentionPolicyListResult { - return page.mbstrplr +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return } -// Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedBackupShortTermRetentionPolicyListResultPage) Values() []ManagedBackupShortTermRetentionPolicy { - if page.mbstrplr.IsEmpty() { - return nil - } - return *page.mbstrplr.Value +// LongTermRetentionManagedInstanceBackupsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) } -// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultPage type. -func NewManagedBackupShortTermRetentionPolicyListResultPage(cur ManagedBackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error)) ManagedBackupShortTermRetentionPolicyListResultPage { - return ManagedBackupShortTermRetentionPolicyListResultPage{ - fn: getNextPage, - mbstrplr: cur, +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// ManagedBackupShortTermRetentionPolicyProperties properties of a short term retention policy -type ManagedBackupShortTermRetentionPolicyProperties struct { - // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. - RetentionDays *int32 `json:"retentionDays,omitempty"` +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return } -// ManagedDatabase a managed database resource. -type ManagedDatabase struct { - autorest.Response `json:"-"` - // ManagedDatabaseProperties - Resource properties. - *ManagedDatabaseProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// LongTermRetentionOperationResultProperties contains the operation result properties for long term +// retention backup operation. +type LongTermRetentionOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // OperationType - READ-ONLY; Operation type. + OperationType *string `json:"operationType,omitempty"` + // FromBackupResourceID - READ-ONLY; Source backup resource id + FromBackupResourceID *string `json:"fromBackupResourceId,omitempty"` + // ToBackupResourceID - READ-ONLY; Target backup resource id + ToBackupResourceID *string `json:"toBackupResourceId,omitempty"` + // TargetBackupStorageRedundancy - READ-ONLY; The storage redundancy type of the copied backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + TargetBackupStorageRedundancy BackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` + // Status - READ-ONLY; Operation status + Status *string `json:"status,omitempty"` + // Message - READ-ONLY; Progress message + Message *string `json:"message,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabase. -func (md ManagedDatabase) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LongTermRetentionOperationResultProperties. +func (ltrorp LongTermRetentionOperationResultProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if md.ManagedDatabaseProperties != nil { - objectMap["properties"] = md.ManagedDatabaseProperties - } - if md.Location != nil { - objectMap["location"] = md.Location - } - if md.Tags != nil { - objectMap["tags"] = md.Tags - } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedDatabase struct. -func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { +// LongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type LongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionPoliciesClient) (LongTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { return err } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var managedDatabaseProperties ManagedDatabaseProperties - err = json.Unmarshal(*v, &managedDatabaseProperties) - if err != nil { - return err - } - md.ManagedDatabaseProperties = &managedDatabaseProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - md.Location = &location - } - case "tags": + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) result(client LongTermRetentionPoliciesClient) (ltrp LongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrp.Response.Response, err = future.GetResult(sender); err == nil && ltrp.Response.Response.StatusCode != http.StatusNoContent { + ltrp, err = client.CreateOrUpdateResponder(ltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", ltrp.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionPolicy a long term retention policy. +type LongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BaseLongTermRetentionPolicyProperties - Resource properties. + *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionPolicy. +func (ltrp LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrp.BaseLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = ltrp.BaseLongTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionPolicy struct. +func (ltrp *LongTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) + var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) if err != nil { return err } - md.Tags = tags + ltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties } case "id": if v != nil { @@ -14209,7 +15359,7 @@ func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { if err != nil { return err } - md.ID = &ID + ltrp.ID = &ID } case "name": if v != nil { @@ -14218,7 +15368,7 @@ func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { if err != nil { return err } - md.Name = &name + ltrp.Name = &name } case "type": if v != nil { @@ -14227,7 +15377,7 @@ func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { if err != nil { return err } - md.Type = &typeVar + ltrp.Type = &typeVar } } } @@ -14235,32 +15385,33 @@ func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { return nil } -// ManagedDatabaseListResult a list of managed databases. -type ManagedDatabaseListResult struct { +// LongTermRetentionPolicyListResult a list of long term retention policies. +type LongTermRetentionPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedDatabase `json:"value,omitempty"` + Value *[]LongTermRetentionPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabaseListResult. -func (mdlr ManagedDatabaseListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for LongTermRetentionPolicyListResult. +func (ltrplr LongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedDatabaseListResultIterator provides access to a complete listing of ManagedDatabase values. -type ManagedDatabaseListResultIterator struct { +// LongTermRetentionPolicyListResultIterator provides access to a complete listing of +// LongTermRetentionPolicy values. +type LongTermRetentionPolicyListResultIterator struct { i int - page ManagedDatabaseListResultPage + page LongTermRetentionPolicyListResultPage } // NextWithContext 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 *ManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *LongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -14285,67 +15436,67 @@ func (iter *ManagedDatabaseListResultIterator) NextWithContext(ctx context.Conte // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedDatabaseListResultIterator) Next() error { +func (iter *LongTermRetentionPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedDatabaseListResultIterator) NotDone() bool { +func (iter LongTermRetentionPolicyListResultIterator) 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 ManagedDatabaseListResultIterator) Response() ManagedDatabaseListResult { +func (iter LongTermRetentionPolicyListResultIterator) Response() LongTermRetentionPolicyListResult { 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 ManagedDatabaseListResultIterator) Value() ManagedDatabase { +func (iter LongTermRetentionPolicyListResultIterator) Value() LongTermRetentionPolicy { if !iter.page.NotDone() { - return ManagedDatabase{} + return LongTermRetentionPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedDatabaseListResultIterator type. -func NewManagedDatabaseListResultIterator(page ManagedDatabaseListResultPage) ManagedDatabaseListResultIterator { - return ManagedDatabaseListResultIterator{page: page} +// Creates a new instance of the LongTermRetentionPolicyListResultIterator type. +func NewLongTermRetentionPolicyListResultIterator(page LongTermRetentionPolicyListResultPage) LongTermRetentionPolicyListResultIterator { + return LongTermRetentionPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mdlr ManagedDatabaseListResult) IsEmpty() bool { - return mdlr.Value == nil || len(*mdlr.Value) == 0 +func (ltrplr LongTermRetentionPolicyListResult) IsEmpty() bool { + return ltrplr.Value == nil || len(*ltrplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mdlr ManagedDatabaseListResult) hasNextLink() bool { - return mdlr.NextLink != nil && len(*mdlr.NextLink) != 0 +func (ltrplr LongTermRetentionPolicyListResult) hasNextLink() bool { + return ltrplr.NextLink != nil && len(*ltrplr.NextLink) != 0 } -// managedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// longTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mdlr ManagedDatabaseListResult) managedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mdlr.hasNextLink() { +func (ltrplr LongTermRetentionPolicyListResult) longTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mdlr.NextLink))) + autorest.WithBaseURL(to.String(ltrplr.NextLink))) } -// ManagedDatabaseListResultPage contains a page of ManagedDatabase values. -type ManagedDatabaseListResultPage struct { - fn func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error) - mdlr ManagedDatabaseListResult +// LongTermRetentionPolicyListResultPage contains a page of LongTermRetentionPolicy values. +type LongTermRetentionPolicyListResultPage struct { + fn func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error) + ltrplr LongTermRetentionPolicyListResult } // NextWithContext 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 *ManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *LongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -14355,11 +15506,11 @@ func (page *ManagedDatabaseListResultPage) NextWithContext(ctx context.Context) }() } for { - next, err := page.fn(ctx, page.mdlr) + next, err := page.fn(ctx, page.ltrplr) if err != nil { return err } - page.mdlr = next + page.ltrplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -14370,151 +15521,153 @@ func (page *ManagedDatabaseListResultPage) NextWithContext(ctx context.Context) // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedDatabaseListResultPage) Next() error { +func (page *LongTermRetentionPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedDatabaseListResultPage) NotDone() bool { - return !page.mdlr.IsEmpty() +func (page LongTermRetentionPolicyListResultPage) NotDone() bool { + return !page.ltrplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedDatabaseListResultPage) Response() ManagedDatabaseListResult { - return page.mdlr +func (page LongTermRetentionPolicyListResultPage) Response() LongTermRetentionPolicyListResult { + return page.ltrplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedDatabaseListResultPage) Values() []ManagedDatabase { - if page.mdlr.IsEmpty() { +func (page LongTermRetentionPolicyListResultPage) Values() []LongTermRetentionPolicy { + if page.ltrplr.IsEmpty() { return nil } - return *page.mdlr.Value + return *page.ltrplr.Value } -// Creates a new instance of the ManagedDatabaseListResultPage type. -func NewManagedDatabaseListResultPage(cur ManagedDatabaseListResult, getNextPage func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error)) ManagedDatabaseListResultPage { - return ManagedDatabaseListResultPage{ - fn: getNextPage, - mdlr: cur, +// Creates a new instance of the LongTermRetentionPolicyListResultPage type. +func NewLongTermRetentionPolicyListResultPage(cur LongTermRetentionPolicyListResult, getNextPage func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error)) LongTermRetentionPolicyListResultPage { + return LongTermRetentionPolicyListResultPage{ + fn: getNextPage, + ltrplr: cur, } } -// ManagedDatabaseProperties the managed database's properties. -type ManagedDatabaseProperties struct { - // Collation - Collation of the managed database. - Collation *string `json:"collation,omitempty"` - // Status - READ-ONLY; Status of the database. Possible values include: 'ManagedDatabaseStatusOnline', 'ManagedDatabaseStatusOffline', 'ManagedDatabaseStatusShutdown', 'ManagedDatabaseStatusCreating', 'ManagedDatabaseStatusInaccessible', 'ManagedDatabaseStatusRestoring', 'ManagedDatabaseStatusUpdating' - Status ManagedDatabaseStatus `json:"status,omitempty"` - // CreationDate - READ-ONLY; Creation date of the database. - CreationDate *date.Time `json:"creationDate,omitempty"` - // EarliestRestorePoint - READ-ONLY; Earliest restore point in time for point in time restore. - EarliestRestorePoint *date.Time `json:"earliestRestorePoint,omitempty"` - // RestorePointInTime - Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. - RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` - // DefaultSecondaryLocation - READ-ONLY; Geo paired region. - DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` - // CatalogCollation - Collation of the metadata catalog. Possible values include: 'CatalogCollationTypeDATABASEDEFAULT', 'CatalogCollationTypeSQLLatin1GeneralCP1CIAS' - CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` - // CreateMode - Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a long term retention backup (longTermRetentionBackupResourceId required). Possible values include: 'ManagedDatabaseCreateModeDefault', 'ManagedDatabaseCreateModeRestoreExternalBackup', 'ManagedDatabaseCreateModePointInTimeRestore', 'ManagedDatabaseCreateModeRecovery', 'ManagedDatabaseCreateModeRestoreLongTermRetentionBackup' - CreateMode ManagedDatabaseCreateMode `json:"createMode,omitempty"` - // StorageContainerURI - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri of the storage container where backups for this restore are stored. - StorageContainerURI *string `json:"storageContainerUri,omitempty"` - // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. - SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` - // RestorableDroppedDatabaseID - The restorable dropped database resource id to restore when creating this database. - RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` - // StorageContainerSasToken - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. - StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` - // FailoverGroupID - READ-ONLY; Instance Failover Group resource identifier that this managed database belongs to. - FailoverGroupID *string `json:"failoverGroupId,omitempty"` - // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. - RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` - // LongTermRetentionBackupResourceID - The name of the Long Term Retention backup to be used for restore of this managed database. - LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` - // AutoCompleteRestore - Whether to auto complete restore of this managed database. - AutoCompleteRestore *bool `json:"autoCompleteRestore,omitempty"` - // LastBackupName - Last backup file name for restore of this managed database. - LastBackupName *string `json:"lastBackupName,omitempty"` +// MaintenanceConfigurationCapability the maintenance configuration capability +type MaintenanceConfigurationCapability struct { + // Name - READ-ONLY; Maintenance configuration name + Name *string `json:"name,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the maintenance configuration. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabaseProperties. -func (mdp ManagedDatabaseProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for MaintenanceConfigurationCapability. +func (mcc MaintenanceConfigurationCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mdp.Collation != nil { - objectMap["collation"] = mdp.Collation + if mcc.Reason != nil { + objectMap["reason"] = mcc.Reason } - if mdp.RestorePointInTime != nil { - objectMap["restorePointInTime"] = mdp.RestorePointInTime - } - if mdp.CatalogCollation != "" { - objectMap["catalogCollation"] = mdp.CatalogCollation - } - if mdp.CreateMode != "" { - objectMap["createMode"] = mdp.CreateMode - } - if mdp.StorageContainerURI != nil { - objectMap["storageContainerUri"] = mdp.StorageContainerURI - } - if mdp.SourceDatabaseID != nil { - objectMap["sourceDatabaseId"] = mdp.SourceDatabaseID - } - if mdp.RestorableDroppedDatabaseID != nil { - objectMap["restorableDroppedDatabaseId"] = mdp.RestorableDroppedDatabaseID - } - if mdp.StorageContainerSasToken != nil { - objectMap["storageContainerSasToken"] = mdp.StorageContainerSasToken - } - if mdp.RecoverableDatabaseID != nil { - objectMap["recoverableDatabaseId"] = mdp.RecoverableDatabaseID - } - if mdp.LongTermRetentionBackupResourceID != nil { - objectMap["longTermRetentionBackupResourceId"] = mdp.LongTermRetentionBackupResourceID - } - if mdp.AutoCompleteRestore != nil { - objectMap["autoCompleteRestore"] = mdp.AutoCompleteRestore - } - if mdp.LastBackupName != nil { - objectMap["lastBackupName"] = mdp.LastBackupName + return json.Marshal(objectMap) +} + +// MaintenanceWindowOptions maintenance window options. +type MaintenanceWindowOptions struct { + autorest.Response `json:"-"` + // MaintenanceWindowOptionsProperties - Resource properties. + *MaintenanceWindowOptionsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaintenanceWindowOptions. +func (mwo MaintenanceWindowOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mwo.MaintenanceWindowOptionsProperties != nil { + objectMap["properties"] = mwo.MaintenanceWindowOptionsProperties } return json.Marshal(objectMap) } -// ManagedDatabaseRestoreDetailsProperties the managed database's restore details properties. -type ManagedDatabaseRestoreDetailsProperties struct { - // Status - READ-ONLY; Restore status. - Status *string `json:"status,omitempty"` - // CurrentRestoringFileName - READ-ONLY; Current restoring file name. - CurrentRestoringFileName *string `json:"currentRestoringFileName,omitempty"` - // LastRestoredFileName - READ-ONLY; Last restored file name. - LastRestoredFileName *string `json:"lastRestoredFileName,omitempty"` - // LastRestoredFileTime - READ-ONLY; Last restored file time. - LastRestoredFileTime *date.Time `json:"lastRestoredFileTime,omitempty"` - // PercentCompleted - READ-ONLY; Percent completed. - PercentCompleted *float64 `json:"percentCompleted,omitempty"` - // UnrestorableFiles - READ-ONLY; List of unrestorable files. - UnrestorableFiles *[]string `json:"unrestorableFiles,omitempty"` - // NumberOfFilesDetected - READ-ONLY; Number of files detected. - NumberOfFilesDetected *int64 `json:"numberOfFilesDetected,omitempty"` - // LastUploadedFileName - READ-ONLY; Last uploaded file name. - LastUploadedFileName *string `json:"lastUploadedFileName,omitempty"` - // LastUploadedFileTime - READ-ONLY; Last uploaded file time. - LastUploadedFileTime *date.Time `json:"lastUploadedFileTime,omitempty"` - // BlockReason - READ-ONLY; The reason why restore is in Blocked state. - BlockReason *string `json:"blockReason,omitempty"` +// UnmarshalJSON is the custom unmarshaler for MaintenanceWindowOptions struct. +func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var maintenanceWindowOptionsProperties MaintenanceWindowOptionsProperties + err = json.Unmarshal(*v, &maintenanceWindowOptionsProperties) + if err != nil { + return err + } + mwo.MaintenanceWindowOptionsProperties = &maintenanceWindowOptionsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mwo.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mwo.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mwo.Type = &typeVar + } + } + } + + return nil } -// MarshalJSON is the custom marshaler for ManagedDatabaseRestoreDetailsProperties. -func (mdrdp ManagedDatabaseRestoreDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// MaintenanceWindowOptionsProperties maintenance window options properties. +type MaintenanceWindowOptionsProperties struct { + // IsEnabled - Whether maintenance windows are enabled for the database. + IsEnabled *bool `json:"isEnabled,omitempty"` + // MaintenanceWindowCycles - Available maintenance cycles e.g. {Saturday, 0, 48*60}, {Wednesday, 0, 24*60}. + MaintenanceWindowCycles *[]MaintenanceWindowTimeRange `json:"maintenanceWindowCycles,omitempty"` + // MinDurationInMinutes - Minimum duration of maintenance window. + MinDurationInMinutes *int32 `json:"minDurationInMinutes,omitempty"` + // DefaultDurationInMinutes - Default duration for maintenance window. + DefaultDurationInMinutes *int32 `json:"defaultDurationInMinutes,omitempty"` + // MinCycles - Minimum number of maintenance windows cycles to be set on the database. + MinCycles *int32 `json:"minCycles,omitempty"` + // TimeGranularityInMinutes - Time granularity in minutes for maintenance windows. + TimeGranularityInMinutes *int32 `json:"timeGranularityInMinutes,omitempty"` + // AllowMultipleMaintenanceWindowsPerCycle - Whether we allow multiple maintenance windows per cycle. + AllowMultipleMaintenanceWindowsPerCycle *bool `json:"allowMultipleMaintenanceWindowsPerCycle,omitempty"` } -// ManagedDatabaseRestoreDetailsResult a managed database restore details. -type ManagedDatabaseRestoreDetailsResult struct { +// MaintenanceWindows maintenance windows. +type MaintenanceWindows struct { autorest.Response `json:"-"` - // ManagedDatabaseRestoreDetailsProperties - Resource properties. - *ManagedDatabaseRestoreDetailsProperties `json:"properties,omitempty"` + // MaintenanceWindowsProperties - Resource properties. + *MaintenanceWindowsProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -14523,17 +15676,17 @@ type ManagedDatabaseRestoreDetailsResult struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabaseRestoreDetailsResult. -func (mdrdr ManagedDatabaseRestoreDetailsResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for MaintenanceWindows. +func (mw MaintenanceWindows) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mdrdr.ManagedDatabaseRestoreDetailsProperties != nil { - objectMap["properties"] = mdrdr.ManagedDatabaseRestoreDetailsProperties + if mw.MaintenanceWindowsProperties != nil { + objectMap["properties"] = mw.MaintenanceWindowsProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseRestoreDetailsResult struct. -func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for MaintenanceWindows struct. +func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -14543,12 +15696,12 @@ func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) err switch k { case "properties": if v != nil { - var managedDatabaseRestoreDetailsProperties ManagedDatabaseRestoreDetailsProperties - err = json.Unmarshal(*v, &managedDatabaseRestoreDetailsProperties) + var maintenanceWindowsProperties MaintenanceWindowsProperties + err = json.Unmarshal(*v, &maintenanceWindowsProperties) if err != nil { return err } - mdrdr.ManagedDatabaseRestoreDetailsProperties = &managedDatabaseRestoreDetailsProperties + mw.MaintenanceWindowsProperties = &maintenanceWindowsProperties } case "id": if v != nil { @@ -14557,7 +15710,7 @@ func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) err if err != nil { return err } - mdrdr.ID = &ID + mw.ID = &ID } case "name": if v != nil { @@ -14566,7 +15719,7 @@ func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) err if err != nil { return err } - mdrdr.Name = &name + mw.Name = &name } case "type": if v != nil { @@ -14575,7 +15728,7 @@ func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) err if err != nil { return err } - mdrdr.Type = &typeVar + mw.Type = &typeVar } } } @@ -14583,54 +15736,32 @@ func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) err return nil } -// ManagedDatabasesCompleteRestoreFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedDatabasesCompleteRestoreFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedDatabasesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedDatabasesCompleteRestoreFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// MaintenanceWindowsProperties maintenance windows resource properties. +type MaintenanceWindowsProperties struct { + TimeRanges *[]MaintenanceWindowTimeRange `json:"timeRanges,omitempty"` } -// result is the default implementation for ManagedDatabasesCompleteRestoreFuture.Result. -func (future *ManagedDatabasesCompleteRestoreFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCompleteRestoreFuture") - return - } - ar.Response = future.Response() - return +// MaintenanceWindowTimeRange maintenance window time range. +type MaintenanceWindowTimeRange struct { + // DayOfWeek - Day of maintenance window. Possible values include: 'DayOfWeekSunday', 'DayOfWeekMonday', 'DayOfWeekTuesday', 'DayOfWeekWednesday', 'DayOfWeekThursday', 'DayOfWeekFriday', 'DayOfWeekSaturday' + DayOfWeek DayOfWeek `json:"dayOfWeek,omitempty"` + // StartTime - Start time minutes offset from 12am. + StartTime *string `json:"startTime,omitempty"` + // Duration - Duration of maintenance window in minutes. + Duration *string `json:"duration,omitempty"` } -// ManagedDatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedDatabasesCreateOrUpdateFuture struct { +// ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedDatabasesClient) (ManagedDatabase, error) + Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedDatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -14640,40 +15771,40 @@ func (future *ManagedDatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) e return nil } -// result is the default implementation for ManagedDatabasesCreateOrUpdateFuture.Result. -func (future *ManagedDatabasesCreateOrUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { +// result is the default implementation for ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - md.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCreateOrUpdateFuture") + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { - md, err = client.CreateOrUpdateResponder(md.Response.Response) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", md.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") } } return } -// ManagedDatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ManagedDatabasesDeleteFuture struct { +// ManagedBackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedBackupShortTermRetentionPoliciesUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedDatabasesClient) (autorest.Response, error) + Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedDatabasesDeleteFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -14683,28 +15814,34 @@ func (future *ManagedDatabasesDeleteFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for ManagedDatabasesDeleteFuture.Result. -func (future *ManagedDatabasesDeleteFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { +// result is the default implementation for ManagedBackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesDeleteFuture") + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture") return } - ar.Response = future.Response() + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } return } -// ManagedDatabaseSecurityAlertPolicy a managed database security alert policy. -type ManagedDatabaseSecurityAlertPolicy struct { +// ManagedBackupShortTermRetentionPolicy a short term retention policy. +type ManagedBackupShortTermRetentionPolicy struct { autorest.Response `json:"-"` - // SecurityAlertPolicyProperties - Resource properties. - *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ManagedBackupShortTermRetentionPolicyProperties - Resource properties. + *ManagedBackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -14713,17 +15850,17 @@ type ManagedDatabaseSecurityAlertPolicy struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicy. -func (mdsap ManagedDatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicy. +func (mbstrp ManagedBackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mdsap.SecurityAlertPolicyProperties != nil { - objectMap["properties"] = mdsap.SecurityAlertPolicyProperties + if mbstrp.ManagedBackupShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = mbstrp.ManagedBackupShortTermRetentionPolicyProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseSecurityAlertPolicy struct. -func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedBackupShortTermRetentionPolicy struct. +func (mbstrp *ManagedBackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -14733,12 +15870,12 @@ func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) erro switch k { case "properties": if v != nil { - var securityAlertPolicyProperties SecurityAlertPolicyProperties - err = json.Unmarshal(*v, &securityAlertPolicyProperties) + var managedBackupShortTermRetentionPolicyProperties ManagedBackupShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &managedBackupShortTermRetentionPolicyProperties) if err != nil { return err } - mdsap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + mbstrp.ManagedBackupShortTermRetentionPolicyProperties = &managedBackupShortTermRetentionPolicyProperties } case "id": if v != nil { @@ -14747,7 +15884,7 @@ func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) erro if err != nil { return err } - mdsap.ID = &ID + mbstrp.ID = &ID } case "name": if v != nil { @@ -14756,7 +15893,7 @@ func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) erro if err != nil { return err } - mdsap.Name = &name + mbstrp.Name = &name } case "type": if v != nil { @@ -14765,7 +15902,7 @@ func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) erro if err != nil { return err } - mdsap.Type = &typeVar + mbstrp.Type = &typeVar } } } @@ -14773,33 +15910,33 @@ func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) erro return nil } -// ManagedDatabaseSecurityAlertPolicyListResult a list of the managed database's security alert policies. -type ManagedDatabaseSecurityAlertPolicyListResult struct { +// ManagedBackupShortTermRetentionPolicyListResult a list of short term retention policies. +type ManagedBackupShortTermRetentionPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedDatabaseSecurityAlertPolicy `json:"value,omitempty"` + Value *[]ManagedBackupShortTermRetentionPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicyListResult. -func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicyListResult. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedDatabaseSecurityAlertPolicyListResultIterator provides access to a complete listing of -// ManagedDatabaseSecurityAlertPolicy values. -type ManagedDatabaseSecurityAlertPolicyListResultIterator struct { +// ManagedBackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of +// ManagedBackupShortTermRetentionPolicy values. +type ManagedBackupShortTermRetentionPolicyListResultIterator struct { i int - page ManagedDatabaseSecurityAlertPolicyListResultPage + page ManagedBackupShortTermRetentionPolicyListResultPage } // NextWithContext 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 *ManagedDatabaseSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedBackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -14824,68 +15961,68 @@ func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) NextWithContex // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) Next() error { +func (iter *ManagedBackupShortTermRetentionPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) NotDone() bool { +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) 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 ManagedDatabaseSecurityAlertPolicyListResultIterator) Response() ManagedDatabaseSecurityAlertPolicyListResult { +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) Response() ManagedBackupShortTermRetentionPolicyListResult { 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 ManagedDatabaseSecurityAlertPolicyListResultIterator) Value() ManagedDatabaseSecurityAlertPolicy { +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) Value() ManagedBackupShortTermRetentionPolicy { if !iter.page.NotDone() { - return ManagedDatabaseSecurityAlertPolicy{} + return ManagedBackupShortTermRetentionPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultIterator type. -func NewManagedDatabaseSecurityAlertPolicyListResultIterator(page ManagedDatabaseSecurityAlertPolicyListResultPage) ManagedDatabaseSecurityAlertPolicyListResultIterator { - return ManagedDatabaseSecurityAlertPolicyListResultIterator{page: page} +// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultIterator type. +func NewManagedBackupShortTermRetentionPolicyListResultIterator(page ManagedBackupShortTermRetentionPolicyListResultPage) ManagedBackupShortTermRetentionPolicyListResultIterator { + return ManagedBackupShortTermRetentionPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) IsEmpty() bool { - return mdsaplr.Value == nil || len(*mdsaplr.Value) == 0 +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) IsEmpty() bool { + return mbstrplr.Value == nil || len(*mbstrplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) hasNextLink() bool { - return mdsaplr.NextLink != nil && len(*mdsaplr.NextLink) != 0 +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) hasNextLink() bool { + return mbstrplr.NextLink != nil && len(*mbstrplr.NextLink) != 0 } -// managedDatabaseSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// managedBackupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) managedDatabaseSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mdsaplr.hasNextLink() { +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) managedBackupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mbstrplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mdsaplr.NextLink))) + autorest.WithBaseURL(to.String(mbstrplr.NextLink))) } -// ManagedDatabaseSecurityAlertPolicyListResultPage contains a page of ManagedDatabaseSecurityAlertPolicy -// values. -type ManagedDatabaseSecurityAlertPolicyListResultPage struct { - fn func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error) - mdsaplr ManagedDatabaseSecurityAlertPolicyListResult +// ManagedBackupShortTermRetentionPolicyListResultPage contains a page of +// ManagedBackupShortTermRetentionPolicy values. +type ManagedBackupShortTermRetentionPolicyListResultPage struct { + fn func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error) + mbstrplr ManagedBackupShortTermRetentionPolicyListResult } // NextWithContext 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 *ManagedDatabaseSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedBackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -14895,11 +16032,11 @@ func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) NextWithContext(ct }() } for { - next, err := page.fn(ctx, page.mdsaplr) + next, err := page.fn(ctx, page.mbstrplr) if err != nil { return err } - page.mdsaplr = next + page.mbstrplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -14910,101 +16047,76 @@ func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) NextWithContext(ct // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) Next() error { +func (page *ManagedBackupShortTermRetentionPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedDatabaseSecurityAlertPolicyListResultPage) NotDone() bool { - return !page.mdsaplr.IsEmpty() +func (page ManagedBackupShortTermRetentionPolicyListResultPage) NotDone() bool { + return !page.mbstrplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Response() ManagedDatabaseSecurityAlertPolicyListResult { - return page.mdsaplr +func (page ManagedBackupShortTermRetentionPolicyListResultPage) Response() ManagedBackupShortTermRetentionPolicyListResult { + return page.mbstrplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Values() []ManagedDatabaseSecurityAlertPolicy { - if page.mdsaplr.IsEmpty() { +func (page ManagedBackupShortTermRetentionPolicyListResultPage) Values() []ManagedBackupShortTermRetentionPolicy { + if page.mbstrplr.IsEmpty() { return nil } - return *page.mdsaplr.Value -} - -// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultPage type. -func NewManagedDatabaseSecurityAlertPolicyListResultPage(cur ManagedDatabaseSecurityAlertPolicyListResult, getNextPage func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error)) ManagedDatabaseSecurityAlertPolicyListResultPage { - return ManagedDatabaseSecurityAlertPolicyListResultPage{ - fn: getNextPage, - mdsaplr: cur, - } -} - -// ManagedDatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ManagedDatabasesUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedDatabasesClient) (ManagedDatabase, error) + return *page.mbstrplr.Value } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedDatabasesUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultPage type. +func NewManagedBackupShortTermRetentionPolicyListResultPage(cur ManagedBackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error)) ManagedBackupShortTermRetentionPolicyListResultPage { + return ManagedBackupShortTermRetentionPolicyListResultPage{ + fn: getNextPage, + mbstrplr: cur, } - future.FutureAPI = &azFuture - future.Result = future.result - return nil } -// result is the default implementation for ManagedDatabasesUpdateFuture.Result. -func (future *ManagedDatabasesUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - md.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { - md, err = client.UpdateResponder(md.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", md.Response.Response, "Failure responding to request") - } - } - return +// ManagedBackupShortTermRetentionPolicyProperties properties of a short term retention policy +type ManagedBackupShortTermRetentionPolicyProperties struct { + // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. + RetentionDays *int32 `json:"retentionDays,omitempty"` } -// ManagedDatabaseUpdate an managed database update. -type ManagedDatabaseUpdate struct { +// ManagedDatabase a managed database resource. +type ManagedDatabase struct { + autorest.Response `json:"-"` // ManagedDatabaseProperties - Resource properties. *ManagedDatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` // Tags - Resource tags. Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedDatabaseUpdate. -func (mdu ManagedDatabaseUpdate) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedDatabase. +func (md ManagedDatabase) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mdu.ManagedDatabaseProperties != nil { - objectMap["properties"] = mdu.ManagedDatabaseProperties + if md.ManagedDatabaseProperties != nil { + objectMap["properties"] = md.ManagedDatabaseProperties } - if mdu.Tags != nil { - objectMap["tags"] = mdu.Tags + if md.Location != nil { + objectMap["location"] = md.Location + } + if md.Tags != nil { + objectMap["tags"] = md.Tags } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseUpdate struct. -func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedDatabase struct. +func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -15019,7 +16131,16 @@ func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { if err != nil { return err } - mdu.ManagedDatabaseProperties = &managedDatabaseProperties + md.ManagedDatabaseProperties = &managedDatabaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + md.Location = &location } case "tags": if v != nil { @@ -15028,7 +16149,34 @@ func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { if err != nil { return err } - mdu.Tags = tags + md.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + md.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + md.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + md.Type = &typeVar } } } @@ -15036,272 +16184,32 @@ func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { return nil } -// ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedDatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +// ManagedDatabaseListResult a list of managed databases. +type ManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. -func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client ManagedDatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture") - return - } - ar.Response = future.Response() - return -} - -// ManagedInstance an Azure SQL managed instance. -type ManagedInstance struct { - autorest.Response `json:"-"` - // Identity - The Azure Active Directory identity of the managed instance. - Identity *ResourceIdentity `json:"identity,omitempty"` - // Sku - Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, BC_Gen5 - Sku *Sku `json:"sku,omitempty"` - // ManagedInstanceProperties - Resource properties. - *ManagedInstanceProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstance. -func (mi ManagedInstance) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mi.Identity != nil { - objectMap["identity"] = mi.Identity - } - if mi.Sku != nil { - objectMap["sku"] = mi.Sku - } - if mi.ManagedInstanceProperties != nil { - objectMap["properties"] = mi.ManagedInstanceProperties - } - if mi.Location != nil { - objectMap["location"] = mi.Location - } - if mi.Tags != nil { - objectMap["tags"] = mi.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ManagedInstance struct. -func (mi *ManagedInstance) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "identity": - if v != nil { - var identity ResourceIdentity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - mi.Identity = &identity - } - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - mi.Sku = &sku - } - case "properties": - if v != nil { - var managedInstanceProperties ManagedInstanceProperties - err = json.Unmarshal(*v, &managedInstanceProperties) - if err != nil { - return err - } - mi.ManagedInstanceProperties = &managedInstanceProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mi.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mi.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mi.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mi.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mi.Type = &typeVar - } - } - } - - return nil -} - -// ManagedInstanceAdministrator an Azure SQL managed instance administrator. -type ManagedInstanceAdministrator struct { - autorest.Response `json:"-"` - // ManagedInstanceAdministratorProperties - Resource properties. - *ManagedInstanceAdministratorProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceAdministrator. -func (mia ManagedInstanceAdministrator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mia.ManagedInstanceAdministratorProperties != nil { - objectMap["properties"] = mia.ManagedInstanceAdministratorProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAdministrator struct. -func (mia *ManagedInstanceAdministrator) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var managedInstanceAdministratorProperties ManagedInstanceAdministratorProperties - err = json.Unmarshal(*v, &managedInstanceAdministratorProperties) - if err != nil { - return err - } - mia.ManagedInstanceAdministratorProperties = &managedInstanceAdministratorProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mia.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mia.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mia.Type = &typeVar - } - } - } - - return nil -} - -// ManagedInstanceAdministratorListResult a list of managed instance administrators. -type ManagedInstanceAdministratorListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceAdministrator `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceAdministratorListResult. -func (mialr ManagedInstanceAdministratorListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedDatabaseListResult. +func (mdlr ManagedDatabaseListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceAdministratorListResultIterator provides access to a complete listing of -// ManagedInstanceAdministrator values. -type ManagedInstanceAdministratorListResultIterator struct { +// ManagedDatabaseListResultIterator provides access to a complete listing of ManagedDatabase values. +type ManagedDatabaseListResultIterator struct { i int - page ManagedInstanceAdministratorListResultPage + page ManagedDatabaseListResultPage } // NextWithContext 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 *ManagedInstanceAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -15326,67 +16234,67 @@ func (iter *ManagedInstanceAdministratorListResultIterator) NextWithContext(ctx // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceAdministratorListResultIterator) Next() error { +func (iter *ManagedDatabaseListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceAdministratorListResultIterator) NotDone() bool { +func (iter ManagedDatabaseListResultIterator) 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 ManagedInstanceAdministratorListResultIterator) Response() ManagedInstanceAdministratorListResult { +func (iter ManagedDatabaseListResultIterator) Response() ManagedDatabaseListResult { 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 ManagedInstanceAdministratorListResultIterator) Value() ManagedInstanceAdministrator { +func (iter ManagedDatabaseListResultIterator) Value() ManagedDatabase { if !iter.page.NotDone() { - return ManagedInstanceAdministrator{} + return ManagedDatabase{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceAdministratorListResultIterator type. -func NewManagedInstanceAdministratorListResultIterator(page ManagedInstanceAdministratorListResultPage) ManagedInstanceAdministratorListResultIterator { - return ManagedInstanceAdministratorListResultIterator{page: page} +// Creates a new instance of the ManagedDatabaseListResultIterator type. +func NewManagedDatabaseListResultIterator(page ManagedDatabaseListResultPage) ManagedDatabaseListResultIterator { + return ManagedDatabaseListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mialr ManagedInstanceAdministratorListResult) IsEmpty() bool { - return mialr.Value == nil || len(*mialr.Value) == 0 +func (mdlr ManagedDatabaseListResult) IsEmpty() bool { + return mdlr.Value == nil || len(*mdlr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mialr ManagedInstanceAdministratorListResult) hasNextLink() bool { - return mialr.NextLink != nil && len(*mialr.NextLink) != 0 +func (mdlr ManagedDatabaseListResult) hasNextLink() bool { + return mdlr.NextLink != nil && len(*mdlr.NextLink) != 0 } -// managedInstanceAdministratorListResultPreparer prepares a request to retrieve the next set of results. +// managedDatabaseListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mialr ManagedInstanceAdministratorListResult) managedInstanceAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mialr.hasNextLink() { +func (mdlr ManagedDatabaseListResult) managedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mdlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mialr.NextLink))) + autorest.WithBaseURL(to.String(mdlr.NextLink))) } -// ManagedInstanceAdministratorListResultPage contains a page of ManagedInstanceAdministrator values. -type ManagedInstanceAdministratorListResultPage struct { - fn func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error) - mialr ManagedInstanceAdministratorListResult +// ManagedDatabaseListResultPage contains a page of ManagedDatabase values. +type ManagedDatabaseListResultPage struct { + fn func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error) + mdlr ManagedDatabaseListResult } // NextWithContext 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 *ManagedInstanceAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -15396,11 +16304,11 @@ func (page *ManagedInstanceAdministratorListResultPage) NextWithContext(ctx cont }() } for { - next, err := page.fn(ctx, page.mialr) + next, err := page.fn(ctx, page.mdlr) if err != nil { return err } - page.mialr = next + page.mdlr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -15411,167 +16319,185 @@ func (page *ManagedInstanceAdministratorListResultPage) NextWithContext(ctx cont // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceAdministratorListResultPage) Next() error { +func (page *ManagedDatabaseListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceAdministratorListResultPage) NotDone() bool { - return !page.mialr.IsEmpty() +func (page ManagedDatabaseListResultPage) NotDone() bool { + return !page.mdlr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceAdministratorListResultPage) Response() ManagedInstanceAdministratorListResult { - return page.mialr +func (page ManagedDatabaseListResultPage) Response() ManagedDatabaseListResult { + return page.mdlr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceAdministratorListResultPage) Values() []ManagedInstanceAdministrator { - if page.mialr.IsEmpty() { +func (page ManagedDatabaseListResultPage) Values() []ManagedDatabase { + if page.mdlr.IsEmpty() { return nil } - return *page.mialr.Value + return *page.mdlr.Value } -// Creates a new instance of the ManagedInstanceAdministratorListResultPage type. -func NewManagedInstanceAdministratorListResultPage(cur ManagedInstanceAdministratorListResult, getNextPage func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error)) ManagedInstanceAdministratorListResultPage { - return ManagedInstanceAdministratorListResultPage{ - fn: getNextPage, - mialr: cur, +// Creates a new instance of the ManagedDatabaseListResultPage type. +func NewManagedDatabaseListResultPage(cur ManagedDatabaseListResult, getNextPage func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error)) ManagedDatabaseListResultPage { + return ManagedDatabaseListResultPage{ + fn: getNextPage, + mdlr: cur, } } -// ManagedInstanceAdministratorProperties the properties of a managed instance administrator. -type ManagedInstanceAdministratorProperties struct { - // AdministratorType - Type of the managed instance administrator. - AdministratorType *string `json:"administratorType,omitempty"` - // Login - Login name of the managed instance administrator. - Login *string `json:"login,omitempty"` - // Sid - SID (object ID) of the managed instance administrator. - Sid *uuid.UUID `json:"sid,omitempty"` - // TenantID - Tenant ID of the managed instance administrator. - TenantID *uuid.UUID `json:"tenantId,omitempty"` -} - -// ManagedInstanceAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type ManagedInstanceAdministratorsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstanceAdministratorsClient) (ManagedInstanceAdministrator, error) +// ManagedDatabaseProperties the managed database's properties. +type ManagedDatabaseProperties struct { + // Collation - Collation of the managed database. + Collation *string `json:"collation,omitempty"` + // Status - READ-ONLY; Status of the database. Possible values include: 'ManagedDatabaseStatusOnline', 'ManagedDatabaseStatusOffline', 'ManagedDatabaseStatusShutdown', 'ManagedDatabaseStatusCreating', 'ManagedDatabaseStatusInaccessible', 'ManagedDatabaseStatusRestoring', 'ManagedDatabaseStatusUpdating' + Status ManagedDatabaseStatus `json:"status,omitempty"` + // CreationDate - READ-ONLY; Creation date of the database. + CreationDate *date.Time `json:"creationDate,omitempty"` + // EarliestRestorePoint - READ-ONLY; Earliest restore point in time for point in time restore. + EarliestRestorePoint *date.Time `json:"earliestRestorePoint,omitempty"` + // RestorePointInTime - Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; Geo paired region. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'CatalogCollationTypeDATABASEDEFAULT', 'CatalogCollationTypeSQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // CreateMode - Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a long term retention backup (longTermRetentionBackupResourceId required). Possible values include: 'ManagedDatabaseCreateModeDefault', 'ManagedDatabaseCreateModeRestoreExternalBackup', 'ManagedDatabaseCreateModePointInTimeRestore', 'ManagedDatabaseCreateModeRecovery', 'ManagedDatabaseCreateModeRestoreLongTermRetentionBackup' + CreateMode ManagedDatabaseCreateMode `json:"createMode,omitempty"` + // StorageContainerURI - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri of the storage container where backups for this restore are stored. + StorageContainerURI *string `json:"storageContainerUri,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The restorable dropped database resource id to restore when creating this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // StorageContainerSasToken - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. + StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` + // FailoverGroupID - READ-ONLY; Instance Failover Group resource identifier that this managed database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // LongTermRetentionBackupResourceID - The name of the Long Term Retention backup to be used for restore of this managed database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // AutoCompleteRestore - Whether to auto complete restore of this managed database. + AutoCompleteRestore *bool `json:"autoCompleteRestore,omitempty"` + // LastBackupName - Last backup file name for restore of this managed database. + LastBackupName *string `json:"lastBackupName,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// MarshalJSON is the custom marshaler for ManagedDatabaseProperties. +func (mdp ManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdp.Collation != nil { + objectMap["collation"] = mdp.Collation } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedInstanceAdministratorsCreateOrUpdateFuture.Result. -func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) result(client ManagedInstanceAdministratorsClient) (mia ManagedInstanceAdministrator, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return + if mdp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mdp.RestorePointInTime } - if !done { - mia.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsCreateOrUpdateFuture") - return + if mdp.CatalogCollation != "" { + objectMap["catalogCollation"] = mdp.CatalogCollation } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mia.Response.Response, err = future.GetResult(sender); err == nil && mia.Response.Response.StatusCode != http.StatusNoContent { - mia, err = client.CreateOrUpdateResponder(mia.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", mia.Response.Response, "Failure responding to request") - } + if mdp.CreateMode != "" { + objectMap["createMode"] = mdp.CreateMode } - return -} - -// ManagedInstanceAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedInstanceAdministratorsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstanceAdministratorsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err + if mdp.StorageContainerURI != nil { + objectMap["storageContainerUri"] = mdp.StorageContainerURI } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedInstanceAdministratorsDeleteFuture.Result. -func (future *ManagedInstanceAdministratorsDeleteFuture) result(client ManagedInstanceAdministratorsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") - return + if mdp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = mdp.SourceDatabaseID } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsDeleteFuture") - return + if mdp.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = mdp.RestorableDroppedDatabaseID } - ar.Response = future.Response() - return -} - -// ManagedInstanceAzureADOnlyAuthentication azure Active Directory only authentication. -type ManagedInstanceAzureADOnlyAuthentication struct { - autorest.Response `json:"-"` - // ManagedInstanceAzureADOnlyAuthProperties - Resource properties. - *ManagedInstanceAzureADOnlyAuthProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthentication. -func (miaaoa ManagedInstanceAzureADOnlyAuthentication) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if miaaoa.ManagedInstanceAzureADOnlyAuthProperties != nil { - objectMap["properties"] = miaaoa.ManagedInstanceAzureADOnlyAuthProperties + if mdp.StorageContainerSasToken != nil { + objectMap["storageContainerSasToken"] = mdp.StorageContainerSasToken + } + if mdp.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = mdp.RecoverableDatabaseID + } + if mdp.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = mdp.LongTermRetentionBackupResourceID + } + if mdp.AutoCompleteRestore != nil { + objectMap["autoCompleteRestore"] = mdp.AutoCompleteRestore + } + if mdp.LastBackupName != nil { + objectMap["lastBackupName"] = mdp.LastBackupName } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAzureADOnlyAuthentication struct. -func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var managedInstanceAzureADOnlyAuthProperties ManagedInstanceAzureADOnlyAuthProperties - err = json.Unmarshal(*v, &managedInstanceAzureADOnlyAuthProperties) - if err != nil { - return err - } - miaaoa.ManagedInstanceAzureADOnlyAuthProperties = &managedInstanceAzureADOnlyAuthProperties +// ManagedDatabaseRestoreDetailsProperties the managed database's restore details properties. +type ManagedDatabaseRestoreDetailsProperties struct { + // Status - READ-ONLY; Restore status. + Status *string `json:"status,omitempty"` + // CurrentRestoringFileName - READ-ONLY; Current restoring file name. + CurrentRestoringFileName *string `json:"currentRestoringFileName,omitempty"` + // LastRestoredFileName - READ-ONLY; Last restored file name. + LastRestoredFileName *string `json:"lastRestoredFileName,omitempty"` + // LastRestoredFileTime - READ-ONLY; Last restored file time. + LastRestoredFileTime *date.Time `json:"lastRestoredFileTime,omitempty"` + // PercentCompleted - READ-ONLY; Percent completed. + PercentCompleted *float64 `json:"percentCompleted,omitempty"` + // UnrestorableFiles - READ-ONLY; List of unrestorable files. + UnrestorableFiles *[]string `json:"unrestorableFiles,omitempty"` + // NumberOfFilesDetected - READ-ONLY; Number of files detected. + NumberOfFilesDetected *int64 `json:"numberOfFilesDetected,omitempty"` + // LastUploadedFileName - READ-ONLY; Last uploaded file name. + LastUploadedFileName *string `json:"lastUploadedFileName,omitempty"` + // LastUploadedFileTime - READ-ONLY; Last uploaded file time. + LastUploadedFileTime *date.Time `json:"lastUploadedFileTime,omitempty"` + // BlockReason - READ-ONLY; The reason why restore is in Blocked state. + BlockReason *string `json:"blockReason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseRestoreDetailsProperties. +func (mdrdp ManagedDatabaseRestoreDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseRestoreDetailsResult a managed database restore details. +type ManagedDatabaseRestoreDetailsResult struct { + autorest.Response `json:"-"` + // ManagedDatabaseRestoreDetailsProperties - Resource properties. + *ManagedDatabaseRestoreDetailsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseRestoreDetailsResult. +func (mdrdr ManagedDatabaseRestoreDetailsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdrdr.ManagedDatabaseRestoreDetailsProperties != nil { + objectMap["properties"] = mdrdr.ManagedDatabaseRestoreDetailsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseRestoreDetailsResult struct. +func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedDatabaseRestoreDetailsProperties ManagedDatabaseRestoreDetailsProperties + err = json.Unmarshal(*v, &managedDatabaseRestoreDetailsProperties) + if err != nil { + return err + } + mdrdr.ManagedDatabaseRestoreDetailsProperties = &managedDatabaseRestoreDetailsProperties } case "id": if v != nil { @@ -15580,7 +16506,7 @@ func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byt if err != nil { return err } - miaaoa.ID = &ID + mdrdr.ID = &ID } case "name": if v != nil { @@ -15589,7 +16515,7 @@ func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byt if err != nil { return err } - miaaoa.Name = &name + mdrdr.Name = &name } case "type": if v != nil { @@ -15598,7 +16524,7 @@ func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byt if err != nil { return err } - miaaoa.Type = &typeVar + mdrdr.Type = &typeVar } } } @@ -15606,17 +16532,17 @@ func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byt return nil } -// ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture struct { +// ManagedDatabasesCompleteRestoreFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedDatabasesCompleteRestoreFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (ManagedInstanceAzureADOnlyAuthentication, error) + Result func(ManagedDatabasesClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedDatabasesCompleteRestoreFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -15626,40 +16552,77 @@ func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) Unm return nil } -// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture.Result. -func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (miaaoa ManagedInstanceAzureADOnlyAuthentication, err error) { +// result is the default implementation for ManagedDatabasesCompleteRestoreFuture.Result. +func (future *ManagedDatabasesCompleteRestoreFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Polling failure") return } if !done { - miaaoa.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture") + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCompleteRestoreFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedDatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedDatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (ManagedDatabase, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesCreateOrUpdateFuture.Result. +func (future *ManagedDatabasesCreateOrUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + md.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if miaaoa.Response.Response, err = future.GetResult(sender); err == nil && miaaoa.Response.Response.StatusCode != http.StatusNoContent { - miaaoa, err = client.CreateOrUpdateResponder(miaaoa.Response.Response) + if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { + md, err = client.CreateOrUpdateResponder(md.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", miaaoa.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", md.Response.Response, "Failure responding to request") } } return } -// ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture struct { +// ManagedDatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesDeleteFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (autorest.Response, error) + Result func(ManagedDatabasesClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedDatabasesDeleteFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -15669,50 +16632,123 @@ func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJS return nil } -// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture.Result. -func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (ar autorest.Response, err error) { +// result is the default implementation for ManagedDatabasesDeleteFuture.Result. +func (future *ManagedDatabasesDeleteFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture") + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesDeleteFuture") return } ar.Response = future.Response() return } -// ManagedInstanceAzureADOnlyAuthListResult a list of active directory only authentications. -type ManagedInstanceAzureADOnlyAuthListResult struct { +// ManagedDatabaseSecurityAlertPolicy a managed database security alert policy. +type ManagedDatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicy. +func (mdsap ManagedDatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdsap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = mdsap.SecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseSecurityAlertPolicy struct. +func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + mdsap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdsap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdsap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdsap.Type = &typeVar + } + } + } + + return nil +} + +// ManagedDatabaseSecurityAlertPolicyListResult a list of the managed database's security alert policies. +type ManagedDatabaseSecurityAlertPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceAzureADOnlyAuthentication `json:"value,omitempty"` + Value *[]ManagedDatabaseSecurityAlertPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthListResult. -func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicyListResult. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceAzureADOnlyAuthListResultIterator provides access to a complete listing of -// ManagedInstanceAzureADOnlyAuthentication values. -type ManagedInstanceAzureADOnlyAuthListResultIterator struct { +// ManagedDatabaseSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ManagedDatabaseSecurityAlertPolicy values. +type ManagedDatabaseSecurityAlertPolicyListResultIterator struct { i int - page ManagedInstanceAzureADOnlyAuthListResultPage + page ManagedDatabaseSecurityAlertPolicyListResultPage } // NextWithContext 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 *ManagedInstanceAzureADOnlyAuthListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -15737,68 +16773,68 @@ func (iter *ManagedInstanceAzureADOnlyAuthListResultIterator) NextWithContext(ct // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceAzureADOnlyAuthListResultIterator) Next() error { +func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) NotDone() bool { +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) 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 ManagedInstanceAzureADOnlyAuthListResultIterator) Response() ManagedInstanceAzureADOnlyAuthListResult { +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) Response() ManagedDatabaseSecurityAlertPolicyListResult { 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 ManagedInstanceAzureADOnlyAuthListResultIterator) Value() ManagedInstanceAzureADOnlyAuthentication { +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) Value() ManagedDatabaseSecurityAlertPolicy { if !iter.page.NotDone() { - return ManagedInstanceAzureADOnlyAuthentication{} + return ManagedDatabaseSecurityAlertPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultIterator type. -func NewManagedInstanceAzureADOnlyAuthListResultIterator(page ManagedInstanceAzureADOnlyAuthListResultPage) ManagedInstanceAzureADOnlyAuthListResultIterator { - return ManagedInstanceAzureADOnlyAuthListResultIterator{page: page} +// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultIterator type. +func NewManagedDatabaseSecurityAlertPolicyListResultIterator(page ManagedDatabaseSecurityAlertPolicyListResultPage) ManagedDatabaseSecurityAlertPolicyListResultIterator { + return ManagedDatabaseSecurityAlertPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) IsEmpty() bool { - return miaaoalr.Value == nil || len(*miaaoalr.Value) == 0 +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) IsEmpty() bool { + return mdsaplr.Value == nil || len(*mdsaplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) hasNextLink() bool { - return miaaoalr.NextLink != nil && len(*miaaoalr.NextLink) != 0 +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) hasNextLink() bool { + return mdsaplr.NextLink != nil && len(*mdsaplr.NextLink) != 0 } -// managedInstanceAzureADOnlyAuthListResultPreparer prepares a request to retrieve the next set of results. +// managedDatabaseSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) managedInstanceAzureADOnlyAuthListResultPreparer(ctx context.Context) (*http.Request, error) { - if !miaaoalr.hasNextLink() { +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) managedDatabaseSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mdsaplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(miaaoalr.NextLink))) + autorest.WithBaseURL(to.String(mdsaplr.NextLink))) } -// ManagedInstanceAzureADOnlyAuthListResultPage contains a page of ManagedInstanceAzureADOnlyAuthentication +// ManagedDatabaseSecurityAlertPolicyListResultPage contains a page of ManagedDatabaseSecurityAlertPolicy // values. -type ManagedInstanceAzureADOnlyAuthListResultPage struct { - fn func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error) - miaaoalr ManagedInstanceAzureADOnlyAuthListResult +type ManagedDatabaseSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error) + mdsaplr ManagedDatabaseSecurityAlertPolicyListResult } // NextWithContext 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 *ManagedInstanceAzureADOnlyAuthListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -15808,11 +16844,11 @@ func (page *ManagedInstanceAzureADOnlyAuthListResultPage) NextWithContext(ctx co }() } for { - next, err := page.fn(ctx, page.miaaoalr) + next, err := page.fn(ctx, page.mdsaplr) if err != nil { return err } - page.miaaoalr = next + page.mdsaplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -15823,94 +16859,101 @@ func (page *ManagedInstanceAzureADOnlyAuthListResultPage) NextWithContext(ctx co // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceAzureADOnlyAuthListResultPage) Next() error { +func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceAzureADOnlyAuthListResultPage) NotDone() bool { - return !page.miaaoalr.IsEmpty() +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.mdsaplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceAzureADOnlyAuthListResultPage) Response() ManagedInstanceAzureADOnlyAuthListResult { - return page.miaaoalr +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Response() ManagedDatabaseSecurityAlertPolicyListResult { + return page.mdsaplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceAzureADOnlyAuthListResultPage) Values() []ManagedInstanceAzureADOnlyAuthentication { - if page.miaaoalr.IsEmpty() { +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Values() []ManagedDatabaseSecurityAlertPolicy { + if page.mdsaplr.IsEmpty() { return nil } - return *page.miaaoalr.Value + return *page.mdsaplr.Value } -// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultPage type. -func NewManagedInstanceAzureADOnlyAuthListResultPage(cur ManagedInstanceAzureADOnlyAuthListResult, getNextPage func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error)) ManagedInstanceAzureADOnlyAuthListResultPage { - return ManagedInstanceAzureADOnlyAuthListResultPage{ - fn: getNextPage, - miaaoalr: cur, +// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultPage type. +func NewManagedDatabaseSecurityAlertPolicyListResultPage(cur ManagedDatabaseSecurityAlertPolicyListResult, getNextPage func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error)) ManagedDatabaseSecurityAlertPolicyListResultPage { + return ManagedDatabaseSecurityAlertPolicyListResultPage{ + fn: getNextPage, + mdsaplr: cur, } } -// ManagedInstanceAzureADOnlyAuthProperties properties of a active directory only authentication for -// Managed Instance. -type ManagedInstanceAzureADOnlyAuthProperties struct { - // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. - AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +// ManagedDatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (ManagedDatabase, error) } -// ManagedInstanceEditionCapability the managed server capability -type ManagedInstanceEditionCapability struct { - // Name - READ-ONLY; The managed server version name. - Name *string `json:"name,omitempty"` - // SupportedFamilies - READ-ONLY; The supported families. - SupportedFamilies *[]ManagedInstanceFamilyCapability `json:"supportedFamilies,omitempty"` - // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition - SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` - // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// MarshalJSON is the custom marshaler for ManagedInstanceEditionCapability. -func (miec ManagedInstanceEditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if miec.Reason != nil { - objectMap["reason"] = miec.Reason +// result is the default implementation for ManagedDatabasesUpdateFuture.Result. +func (future *ManagedDatabasesUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return } - return json.Marshal(objectMap) + if !done { + md.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { + md, err = client.UpdateResponder(md.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", md.Response.Response, "Failure responding to request") + } + } + return } -// ManagedInstanceEncryptionProtector the managed instance encryption protector. -type ManagedInstanceEncryptionProtector struct { - autorest.Response `json:"-"` - // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. - Kind *string `json:"kind,omitempty"` - // ManagedInstanceEncryptionProtectorProperties - Resource properties. - *ManagedInstanceEncryptionProtectorProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// ManagedDatabaseUpdate an managed database update. +type ManagedDatabaseUpdate struct { + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` } -// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtector. -func (miep ManagedInstanceEncryptionProtector) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedDatabaseUpdate. +func (mdu ManagedDatabaseUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if miep.ManagedInstanceEncryptionProtectorProperties != nil { - objectMap["properties"] = miep.ManagedInstanceEncryptionProtectorProperties + if mdu.ManagedDatabaseProperties != nil { + objectMap["properties"] = mdu.ManagedDatabaseProperties + } + if mdu.Tags != nil { + objectMap["tags"] = mdu.Tags } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceEncryptionProtector struct. -func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseUpdate struct. +func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -15918,50 +16961,23 @@ func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error } for k, v := range m { switch k { - case "kind": - if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - miep.Kind = &kind - } case "properties": if v != nil { - var managedInstanceEncryptionProtectorProperties ManagedInstanceEncryptionProtectorProperties - err = json.Unmarshal(*v, &managedInstanceEncryptionProtectorProperties) - if err != nil { - return err - } - miep.ManagedInstanceEncryptionProtectorProperties = &managedInstanceEncryptionProtectorProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - miep.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) + var managedDatabaseProperties ManagedDatabaseProperties + err = json.Unmarshal(*v, &managedDatabaseProperties) if err != nil { return err } - miep.Name = &name + mdu.ManagedDatabaseProperties = &managedDatabaseProperties } - case "type": + case "tags": if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) + var tags map[string]*string + err = json.Unmarshal(*v, &tags) if err != nil { return err } - miep.Type = &typeVar + mdu.Tags = tags } } } @@ -15969,33 +16985,272 @@ func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error return nil } -// ManagedInstanceEncryptionProtectorListResult a list of managed instance encryption protectors. -type ManagedInstanceEncryptionProtectorListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceEncryptionProtector `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` +// ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) } -// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorListResult. -func (mieplr ManagedInstanceEncryptionProtectorListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// ManagedInstanceEncryptionProtectorListResultIterator provides access to a complete listing of -// ManagedInstanceEncryptionProtector values. -type ManagedInstanceEncryptionProtectorListResultIterator struct { - i int - page ManagedInstanceEncryptionProtectorListResultPage +// result is the default implementation for ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client ManagedDatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return } -// NextWithContext 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 *ManagedInstanceEncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultIterator.NextWithContext") +// ManagedInstance an Azure SQL managed instance. +type ManagedInstance struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the managed instance. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Sku - Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, BC_Gen5 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstance. +func (mi ManagedInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mi.Identity != nil { + objectMap["identity"] = mi.Identity + } + if mi.Sku != nil { + objectMap["sku"] = mi.Sku + } + if mi.ManagedInstanceProperties != nil { + objectMap["properties"] = mi.ManagedInstanceProperties + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.Tags != nil { + objectMap["tags"] = mi.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstance struct. +func (mi *ManagedInstance) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mi.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + mi.Sku = &sku + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + mi.ManagedInstanceProperties = &managedInstanceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mi.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAdministrator an Azure SQL managed instance administrator. +type ManagedInstanceAdministrator struct { + autorest.Response `json:"-"` + // ManagedInstanceAdministratorProperties - Resource properties. + *ManagedInstanceAdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAdministrator. +func (mia ManagedInstanceAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mia.ManagedInstanceAdministratorProperties != nil { + objectMap["properties"] = mia.ManagedInstanceAdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAdministrator struct. +func (mia *ManagedInstanceAdministrator) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceAdministratorProperties ManagedInstanceAdministratorProperties + err = json.Unmarshal(*v, &managedInstanceAdministratorProperties) + if err != nil { + return err + } + mia.ManagedInstanceAdministratorProperties = &managedInstanceAdministratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mia.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mia.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mia.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAdministratorListResult a list of managed instance administrators. +type ManagedInstanceAdministratorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceAdministrator `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAdministratorListResult. +func (mialr ManagedInstanceAdministratorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceAdministratorListResultIterator provides access to a complete listing of +// ManagedInstanceAdministrator values. +type ManagedInstanceAdministratorListResultIterator struct { + i int + page ManagedInstanceAdministratorListResultPage +} + +// NextWithContext 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 *ManagedInstanceAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -16020,68 +17275,67 @@ func (iter *ManagedInstanceEncryptionProtectorListResultIterator) NextWithContex // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceEncryptionProtectorListResultIterator) Next() error { +func (iter *ManagedInstanceAdministratorListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceEncryptionProtectorListResultIterator) NotDone() bool { +func (iter ManagedInstanceAdministratorListResultIterator) 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 ManagedInstanceEncryptionProtectorListResultIterator) Response() ManagedInstanceEncryptionProtectorListResult { +func (iter ManagedInstanceAdministratorListResultIterator) Response() ManagedInstanceAdministratorListResult { 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 ManagedInstanceEncryptionProtectorListResultIterator) Value() ManagedInstanceEncryptionProtector { +func (iter ManagedInstanceAdministratorListResultIterator) Value() ManagedInstanceAdministrator { if !iter.page.NotDone() { - return ManagedInstanceEncryptionProtector{} + return ManagedInstanceAdministrator{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultIterator type. -func NewManagedInstanceEncryptionProtectorListResultIterator(page ManagedInstanceEncryptionProtectorListResultPage) ManagedInstanceEncryptionProtectorListResultIterator { - return ManagedInstanceEncryptionProtectorListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceAdministratorListResultIterator type. +func NewManagedInstanceAdministratorListResultIterator(page ManagedInstanceAdministratorListResultPage) ManagedInstanceAdministratorListResultIterator { + return ManagedInstanceAdministratorListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mieplr ManagedInstanceEncryptionProtectorListResult) IsEmpty() bool { - return mieplr.Value == nil || len(*mieplr.Value) == 0 +func (mialr ManagedInstanceAdministratorListResult) IsEmpty() bool { + return mialr.Value == nil || len(*mialr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mieplr ManagedInstanceEncryptionProtectorListResult) hasNextLink() bool { - return mieplr.NextLink != nil && len(*mieplr.NextLink) != 0 +func (mialr ManagedInstanceAdministratorListResult) hasNextLink() bool { + return mialr.NextLink != nil && len(*mialr.NextLink) != 0 } -// managedInstanceEncryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceAdministratorListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mieplr ManagedInstanceEncryptionProtectorListResult) managedInstanceEncryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mieplr.hasNextLink() { +func (mialr ManagedInstanceAdministratorListResult) managedInstanceAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mialr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mieplr.NextLink))) + autorest.WithBaseURL(to.String(mialr.NextLink))) } -// ManagedInstanceEncryptionProtectorListResultPage contains a page of ManagedInstanceEncryptionProtector -// values. -type ManagedInstanceEncryptionProtectorListResultPage struct { - fn func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error) - mieplr ManagedInstanceEncryptionProtectorListResult +// ManagedInstanceAdministratorListResultPage contains a page of ManagedInstanceAdministrator values. +type ManagedInstanceAdministratorListResultPage struct { + fn func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error) + mialr ManagedInstanceAdministratorListResult } // NextWithContext 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 *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -16091,11 +17345,11 @@ func (page *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ct }() } for { - next, err := page.fn(ctx, page.mieplr) + next, err := page.fn(ctx, page.mialr) if err != nil { return err } - page.mieplr = next + page.mialr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -16106,76 +17360,59 @@ func (page *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ct // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceEncryptionProtectorListResultPage) Next() error { +func (page *ManagedInstanceAdministratorListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceEncryptionProtectorListResultPage) NotDone() bool { - return !page.mieplr.IsEmpty() +func (page ManagedInstanceAdministratorListResultPage) NotDone() bool { + return !page.mialr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceEncryptionProtectorListResultPage) Response() ManagedInstanceEncryptionProtectorListResult { - return page.mieplr +func (page ManagedInstanceAdministratorListResultPage) Response() ManagedInstanceAdministratorListResult { + return page.mialr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceEncryptionProtectorListResultPage) Values() []ManagedInstanceEncryptionProtector { - if page.mieplr.IsEmpty() { +func (page ManagedInstanceAdministratorListResultPage) Values() []ManagedInstanceAdministrator { + if page.mialr.IsEmpty() { return nil } - return *page.mieplr.Value + return *page.mialr.Value } -// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultPage type. -func NewManagedInstanceEncryptionProtectorListResultPage(cur ManagedInstanceEncryptionProtectorListResult, getNextPage func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error)) ManagedInstanceEncryptionProtectorListResultPage { - return ManagedInstanceEncryptionProtectorListResultPage{ - fn: getNextPage, - mieplr: cur, +// Creates a new instance of the ManagedInstanceAdministratorListResultPage type. +func NewManagedInstanceAdministratorListResultPage(cur ManagedInstanceAdministratorListResult, getNextPage func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error)) ManagedInstanceAdministratorListResultPage { + return ManagedInstanceAdministratorListResultPage{ + fn: getNextPage, + mialr: cur, } } -// ManagedInstanceEncryptionProtectorProperties properties for an encryption protector execution. -type ManagedInstanceEncryptionProtectorProperties struct { - // ServerKeyName - The name of the managed instance key. - ServerKeyName *string `json:"serverKeyName,omitempty"` - // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' - ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` - // URI - READ-ONLY; The URI of the server key. - URI *string `json:"uri,omitempty"` - // Thumbprint - READ-ONLY; Thumbprint of the server key. - Thumbprint *string `json:"thumbprint,omitempty"` - // AutoRotationEnabled - Key auto rotation opt-in flag. Either true or false. - AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorProperties. -func (miepp ManagedInstanceEncryptionProtectorProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if miepp.ServerKeyName != nil { - objectMap["serverKeyName"] = miepp.ServerKeyName - } - if miepp.ServerKeyType != "" { - objectMap["serverKeyType"] = miepp.ServerKeyType - } - if miepp.AutoRotationEnabled != nil { - objectMap["autoRotationEnabled"] = miepp.AutoRotationEnabled - } - return json.Marshal(objectMap) +// ManagedInstanceAdministratorProperties the properties of a managed instance administrator. +type ManagedInstanceAdministratorProperties struct { + // AdministratorType - Type of the managed instance administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - Login name of the managed instance administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the managed instance administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the managed instance administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` } -// ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// ManagedInstanceAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the // results of a long-running operation. -type ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture struct { +type ManagedInstanceAdministratorsCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstanceEncryptionProtectorsClient) (ManagedInstanceEncryptionProtector, error) + Result func(ManagedInstanceAdministratorsClient) (ManagedInstanceAdministrator, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -16185,40 +17422,40 @@ func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) Unmarshal return nil } -// result is the default implementation for ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture.Result. -func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (miep ManagedInstanceEncryptionProtector, err error) { +// result is the default implementation for ManagedInstanceAdministratorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) result(client ManagedInstanceAdministratorsClient) (mia ManagedInstanceAdministrator, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - miep.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture") + mia.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if miep.Response.Response, err = future.GetResult(sender); err == nil && miep.Response.Response.StatusCode != http.StatusNoContent { - miep, err = client.CreateOrUpdateResponder(miep.Response.Response) + if mia.Response.Response, err = future.GetResult(sender); err == nil && mia.Response.Response.StatusCode != http.StatusNoContent { + mia, err = client.CreateOrUpdateResponder(mia.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", miep.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", mia.Response.Response, "Failure responding to request") } } return } -// ManagedInstanceEncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type ManagedInstanceEncryptionProtectorsRevalidateFuture struct { +// ManagedInstanceAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceAdministratorsDeleteFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstanceEncryptionProtectorsClient) (autorest.Response, error) + Result func(ManagedInstanceAdministratorsClient) (autorest.Response, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedInstanceAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -16228,71 +17465,28 @@ func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) UnmarshalJSON return nil } -// result is the default implementation for ManagedInstanceEncryptionProtectorsRevalidateFuture.Result. -func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (ar autorest.Response, err error) { +// result is the default implementation for ManagedInstanceAdministratorsDeleteFuture.Result. +func (future *ManagedInstanceAdministratorsDeleteFuture) result(client ManagedInstanceAdministratorsClient) (ar autorest.Response, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") return } if !done { ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsRevalidateFuture") + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsDeleteFuture") return } ar.Response = future.Response() return } -// ManagedInstanceExternalAdministrator properties of a active directory administrator. -type ManagedInstanceExternalAdministrator struct { - // AdministratorType - Type of the sever administrator. Possible values include: 'AdministratorTypeActiveDirectory' - AdministratorType AdministratorType `json:"administratorType,omitempty"` - // PrincipalType - Principal Type of the sever administrator. Possible values include: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeApplication' - PrincipalType PrincipalType `json:"principalType,omitempty"` - // Login - Login name of the server administrator. - Login *string `json:"login,omitempty"` - // Sid - SID (object ID) of the server administrator. - Sid *uuid.UUID `json:"sid,omitempty"` - // TenantID - Tenant ID of the administrator. - TenantID *uuid.UUID `json:"tenantId,omitempty"` - // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. - AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` -} - -// ManagedInstanceFamilyCapability the managed server family capability. -type ManagedInstanceFamilyCapability struct { - // Name - READ-ONLY; Family name. - Name *string `json:"name,omitempty"` - // Sku - READ-ONLY; SKU name. - Sku *string `json:"sku,omitempty"` - // SupportedLicenseTypes - READ-ONLY; List of supported license types. - SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` - // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. - SupportedVcoresValues *[]ManagedInstanceVcoresCapability `json:"supportedVcoresValues,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceFamilyCapability. -func (mifc ManagedInstanceFamilyCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mifc.Reason != nil { - objectMap["reason"] = mifc.Reason - } - return json.Marshal(objectMap) -} - -// ManagedInstanceKey a managed instance key. -type ManagedInstanceKey struct { +// ManagedInstanceAzureADOnlyAuthentication azure Active Directory only authentication. +type ManagedInstanceAzureADOnlyAuthentication struct { autorest.Response `json:"-"` - // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. - Kind *string `json:"kind,omitempty"` - // ManagedInstanceKeyProperties - Resource properties. - *ManagedInstanceKeyProperties `json:"properties,omitempty"` + // ManagedInstanceAzureADOnlyAuthProperties - Resource properties. + *ManagedInstanceAzureADOnlyAuthProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -16301,17 +17495,17 @@ type ManagedInstanceKey struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceKey. -func (mik ManagedInstanceKey) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthentication. +func (miaaoa ManagedInstanceAzureADOnlyAuthentication) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mik.ManagedInstanceKeyProperties != nil { - objectMap["properties"] = mik.ManagedInstanceKeyProperties + if miaaoa.ManagedInstanceAzureADOnlyAuthProperties != nil { + objectMap["properties"] = miaaoa.ManagedInstanceAzureADOnlyAuthProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceKey struct. -func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAzureADOnlyAuthentication struct. +func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -16319,23 +17513,14 @@ func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "kind": - if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - mik.Kind = &kind - } case "properties": if v != nil { - var managedInstanceKeyProperties ManagedInstanceKeyProperties - err = json.Unmarshal(*v, &managedInstanceKeyProperties) + var managedInstanceAzureADOnlyAuthProperties ManagedInstanceAzureADOnlyAuthProperties + err = json.Unmarshal(*v, &managedInstanceAzureADOnlyAuthProperties) if err != nil { return err } - mik.ManagedInstanceKeyProperties = &managedInstanceKeyProperties + miaaoa.ManagedInstanceAzureADOnlyAuthProperties = &managedInstanceAzureADOnlyAuthProperties } case "id": if v != nil { @@ -16344,7 +17529,7 @@ func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { if err != nil { return err } - mik.ID = &ID + miaaoa.ID = &ID } case "name": if v != nil { @@ -16353,7 +17538,7 @@ func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { if err != nil { return err } - mik.Name = &name + miaaoa.Name = &name } case "type": if v != nil { @@ -16362,7 +17547,7 @@ func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { if err != nil { return err } - mik.Type = &typeVar + miaaoa.Type = &typeVar } } } @@ -16370,38 +17555,119 @@ func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { return nil } -// ManagedInstanceKeyListResult a list of managed instance keys. -type ManagedInstanceKeyListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceKey `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceKeyListResult. -func (miklr ManagedInstanceKeyListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (ManagedInstanceAzureADOnlyAuthentication, error) } -// ManagedInstanceKeyListResultIterator provides access to a complete listing of ManagedInstanceKey values. -type ManagedInstanceKeyListResultIterator struct { - i int - page ManagedInstanceKeyListResultPage +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// NextWithContext 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 *ManagedInstanceKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) +// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (miaaoa ManagedInstanceAzureADOnlyAuthentication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miaaoa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miaaoa.Response.Response, err = future.GetResult(sender); err == nil && miaaoa.Response.Response.StatusCode != http.StatusNoContent { + miaaoa, err = client.CreateOrUpdateResponder(miaaoa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", miaaoa.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture.Result. +func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceAzureADOnlyAuthListResult a list of active directory only authentications. +type ManagedInstanceAzureADOnlyAuthListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceAzureADOnlyAuthentication `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthListResult. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceAzureADOnlyAuthListResultIterator provides access to a complete listing of +// ManagedInstanceAzureADOnlyAuthentication values. +type ManagedInstanceAzureADOnlyAuthListResultIterator struct { + i int + page ManagedInstanceAzureADOnlyAuthListResultPage +} + +// NextWithContext 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 *ManagedInstanceAzureADOnlyAuthListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) }() } iter.i++ @@ -16420,67 +17686,68 @@ func (iter *ManagedInstanceKeyListResultIterator) NextWithContext(ctx context.Co // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceKeyListResultIterator) Next() error { +func (iter *ManagedInstanceAzureADOnlyAuthListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceKeyListResultIterator) NotDone() bool { +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) 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 ManagedInstanceKeyListResultIterator) Response() ManagedInstanceKeyListResult { +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) Response() ManagedInstanceAzureADOnlyAuthListResult { 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 ManagedInstanceKeyListResultIterator) Value() ManagedInstanceKey { +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) Value() ManagedInstanceAzureADOnlyAuthentication { if !iter.page.NotDone() { - return ManagedInstanceKey{} + return ManagedInstanceAzureADOnlyAuthentication{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceKeyListResultIterator type. -func NewManagedInstanceKeyListResultIterator(page ManagedInstanceKeyListResultPage) ManagedInstanceKeyListResultIterator { - return ManagedInstanceKeyListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultIterator type. +func NewManagedInstanceAzureADOnlyAuthListResultIterator(page ManagedInstanceAzureADOnlyAuthListResultPage) ManagedInstanceAzureADOnlyAuthListResultIterator { + return ManagedInstanceAzureADOnlyAuthListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (miklr ManagedInstanceKeyListResult) IsEmpty() bool { - return miklr.Value == nil || len(*miklr.Value) == 0 +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) IsEmpty() bool { + return miaaoalr.Value == nil || len(*miaaoalr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (miklr ManagedInstanceKeyListResult) hasNextLink() bool { - return miklr.NextLink != nil && len(*miklr.NextLink) != 0 +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) hasNextLink() bool { + return miaaoalr.NextLink != nil && len(*miaaoalr.NextLink) != 0 } -// managedInstanceKeyListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceAzureADOnlyAuthListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (miklr ManagedInstanceKeyListResult) managedInstanceKeyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !miklr.hasNextLink() { +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) managedInstanceAzureADOnlyAuthListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miaaoalr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(miklr.NextLink))) + autorest.WithBaseURL(to.String(miaaoalr.NextLink))) } -// ManagedInstanceKeyListResultPage contains a page of ManagedInstanceKey values. -type ManagedInstanceKeyListResultPage struct { - fn func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error) - miklr ManagedInstanceKeyListResult +// ManagedInstanceAzureADOnlyAuthListResultPage contains a page of ManagedInstanceAzureADOnlyAuthentication +// values. +type ManagedInstanceAzureADOnlyAuthListResultPage struct { + fn func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error) + miaaoalr ManagedInstanceAzureADOnlyAuthListResult } // NextWithContext 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 *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceAzureADOnlyAuthListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -16490,11 +17757,11 @@ func (page *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Contex }() } for { - next, err := page.fn(ctx, page.miklr) + next, err := page.fn(ctx, page.miaaoalr) if err != nil { return err } - page.miklr = next + page.miaaoalr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -16505,168 +17772,179 @@ func (page *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Contex // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceKeyListResultPage) Next() error { +func (page *ManagedInstanceAzureADOnlyAuthListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceKeyListResultPage) NotDone() bool { - return !page.miklr.IsEmpty() +func (page ManagedInstanceAzureADOnlyAuthListResultPage) NotDone() bool { + return !page.miaaoalr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceKeyListResultPage) Response() ManagedInstanceKeyListResult { - return page.miklr +func (page ManagedInstanceAzureADOnlyAuthListResultPage) Response() ManagedInstanceAzureADOnlyAuthListResult { + return page.miaaoalr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceKeyListResultPage) Values() []ManagedInstanceKey { - if page.miklr.IsEmpty() { +func (page ManagedInstanceAzureADOnlyAuthListResultPage) Values() []ManagedInstanceAzureADOnlyAuthentication { + if page.miaaoalr.IsEmpty() { return nil } - return *page.miklr.Value + return *page.miaaoalr.Value } -// Creates a new instance of the ManagedInstanceKeyListResultPage type. -func NewManagedInstanceKeyListResultPage(cur ManagedInstanceKeyListResult, getNextPage func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error)) ManagedInstanceKeyListResultPage { - return ManagedInstanceKeyListResultPage{ - fn: getNextPage, - miklr: cur, +// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultPage type. +func NewManagedInstanceAzureADOnlyAuthListResultPage(cur ManagedInstanceAzureADOnlyAuthListResult, getNextPage func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error)) ManagedInstanceAzureADOnlyAuthListResultPage { + return ManagedInstanceAzureADOnlyAuthListResultPage{ + fn: getNextPage, + miaaoalr: cur, } } -// ManagedInstanceKeyProperties properties for a key execution. -type ManagedInstanceKeyProperties struct { - // ServerKeyType - The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' - ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` - // URI - The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. - URI *string `json:"uri,omitempty"` - // Thumbprint - READ-ONLY; Thumbprint of the key. - Thumbprint *string `json:"thumbprint,omitempty"` - // CreationDate - READ-ONLY; The key creation date. - CreationDate *date.Time `json:"creationDate,omitempty"` - // AutoRotationEnabled - READ-ONLY; Key auto rotation opt-in flag. Either true or false. - AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` +// ManagedInstanceAzureADOnlyAuthProperties properties of a active directory only authentication for +// Managed Instance. +type ManagedInstanceAzureADOnlyAuthProperties struct { + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceKeyProperties. -func (mikp ManagedInstanceKeyProperties) MarshalJSON() ([]byte, error) { +// ManagedInstanceEditionCapability the managed server capability +type ManagedInstanceEditionCapability struct { + // Name - READ-ONLY; The managed server version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]ManagedInstanceFamilyCapability `json:"supportedFamilies,omitempty"` + // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition + SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEditionCapability. +func (miec ManagedInstanceEditionCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mikp.ServerKeyType != "" { - objectMap["serverKeyType"] = mikp.ServerKeyType - } - if mikp.URI != nil { - objectMap["uri"] = mikp.URI + if miec.Reason != nil { + objectMap["reason"] = miec.Reason } return json.Marshal(objectMap) } -// ManagedInstanceKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedInstanceKeysCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstanceKeysClient) (ManagedInstanceKey, error) +// ManagedInstanceEncryptionProtector the managed instance encryption protector. +type ManagedInstanceEncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceEncryptionProtectorProperties - Resource properties. + *ManagedInstanceEncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtector. +func (miep ManagedInstanceEncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miep.ManagedInstanceEncryptionProtectorProperties != nil { + objectMap["properties"] = miep.ManagedInstanceEncryptionProtectorProperties } - future.FutureAPI = &azFuture - future.Result = future.result - return nil + return json.Marshal(objectMap) } -// result is the default implementation for ManagedInstanceKeysCreateOrUpdateFuture.Result. -func (future *ManagedInstanceKeysCreateOrUpdateFuture) result(client ManagedInstanceKeysClient) (mik ManagedInstanceKey, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceEncryptionProtector struct. +func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mik.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysCreateOrUpdateFuture") - return + return err } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mik.Response.Response, err = future.GetResult(sender); err == nil && mik.Response.Response.StatusCode != http.StatusNoContent { - mik, err = client.CreateOrUpdateResponder(mik.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", mik.Response.Response, "Failure responding to request") + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + miep.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceEncryptionProtectorProperties ManagedInstanceEncryptionProtectorProperties + err = json.Unmarshal(*v, &managedInstanceEncryptionProtectorProperties) + if err != nil { + return err + } + miep.ManagedInstanceEncryptionProtectorProperties = &managedInstanceEncryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miep.Type = &typeVar + } } } - return -} - -// ManagedInstanceKeysDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedInstanceKeysDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstanceKeysClient) (autorest.Response, error) -} -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceKeysDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result return nil } -// result is the default implementation for ManagedInstanceKeysDeleteFuture.Result. -func (future *ManagedInstanceKeysDeleteFuture) result(client ManagedInstanceKeysClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// ManagedInstanceListResult a list of managed instances. -type ManagedInstanceListResult struct { +// ManagedInstanceEncryptionProtectorListResult a list of managed instance encryption protectors. +type ManagedInstanceEncryptionProtectorListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstance `json:"value,omitempty"` + Value *[]ManagedInstanceEncryptionProtector `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceListResult. -func (milr ManagedInstanceListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorListResult. +func (mieplr ManagedInstanceEncryptionProtectorListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. -type ManagedInstanceListResultIterator struct { +// ManagedInstanceEncryptionProtectorListResultIterator provides access to a complete listing of +// ManagedInstanceEncryptionProtector values. +type ManagedInstanceEncryptionProtectorListResultIterator struct { i int - page ManagedInstanceListResultPage + page ManagedInstanceEncryptionProtectorListResultPage } // NextWithContext 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 *ManagedInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceEncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -16691,67 +17969,68 @@ func (iter *ManagedInstanceListResultIterator) NextWithContext(ctx context.Conte // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceListResultIterator) Next() error { +func (iter *ManagedInstanceEncryptionProtectorListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceListResultIterator) NotDone() bool { +func (iter ManagedInstanceEncryptionProtectorListResultIterator) 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 ManagedInstanceListResultIterator) Response() ManagedInstanceListResult { +func (iter ManagedInstanceEncryptionProtectorListResultIterator) Response() ManagedInstanceEncryptionProtectorListResult { 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 ManagedInstanceListResultIterator) Value() ManagedInstance { +func (iter ManagedInstanceEncryptionProtectorListResultIterator) Value() ManagedInstanceEncryptionProtector { if !iter.page.NotDone() { - return ManagedInstance{} + return ManagedInstanceEncryptionProtector{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceListResultIterator type. -func NewManagedInstanceListResultIterator(page ManagedInstanceListResultPage) ManagedInstanceListResultIterator { - return ManagedInstanceListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultIterator type. +func NewManagedInstanceEncryptionProtectorListResultIterator(page ManagedInstanceEncryptionProtectorListResultPage) ManagedInstanceEncryptionProtectorListResultIterator { + return ManagedInstanceEncryptionProtectorListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (milr ManagedInstanceListResult) IsEmpty() bool { - return milr.Value == nil || len(*milr.Value) == 0 +func (mieplr ManagedInstanceEncryptionProtectorListResult) IsEmpty() bool { + return mieplr.Value == nil || len(*mieplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (milr ManagedInstanceListResult) hasNextLink() bool { - return milr.NextLink != nil && len(*milr.NextLink) != 0 +func (mieplr ManagedInstanceEncryptionProtectorListResult) hasNextLink() bool { + return mieplr.NextLink != nil && len(*mieplr.NextLink) != 0 } -// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceEncryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (milr ManagedInstanceListResult) managedInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { - if !milr.hasNextLink() { +func (mieplr ManagedInstanceEncryptionProtectorListResult) managedInstanceEncryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mieplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(milr.NextLink))) + autorest.WithBaseURL(to.String(mieplr.NextLink))) } -// ManagedInstanceListResultPage contains a page of ManagedInstance values. -type ManagedInstanceListResultPage struct { - fn func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error) - milr ManagedInstanceListResult +// ManagedInstanceEncryptionProtectorListResultPage contains a page of ManagedInstanceEncryptionProtector +// values. +type ManagedInstanceEncryptionProtectorListResultPage struct { + fn func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error) + mieplr ManagedInstanceEncryptionProtectorListResult } // NextWithContext 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 *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -16761,11 +18040,11 @@ func (page *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) }() } for { - next, err := page.fn(ctx, page.milr) + next, err := page.fn(ctx, page.mieplr) if err != nil { return err } - page.milr = next + page.mieplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -16776,76 +18055,237 @@ func (page *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceListResultPage) Next() error { +func (page *ManagedInstanceEncryptionProtectorListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceListResultPage) NotDone() bool { - return !page.milr.IsEmpty() +func (page ManagedInstanceEncryptionProtectorListResultPage) NotDone() bool { + return !page.mieplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceListResultPage) Response() ManagedInstanceListResult { - return page.milr +func (page ManagedInstanceEncryptionProtectorListResultPage) Response() ManagedInstanceEncryptionProtectorListResult { + return page.mieplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceListResultPage) Values() []ManagedInstance { - if page.milr.IsEmpty() { +func (page ManagedInstanceEncryptionProtectorListResultPage) Values() []ManagedInstanceEncryptionProtector { + if page.mieplr.IsEmpty() { return nil } - return *page.milr.Value + return *page.mieplr.Value } -// Creates a new instance of the ManagedInstanceListResultPage type. -func NewManagedInstanceListResultPage(cur ManagedInstanceListResult, getNextPage func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error)) ManagedInstanceListResultPage { - return ManagedInstanceListResultPage{ - fn: getNextPage, - milr: cur, +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultPage type. +func NewManagedInstanceEncryptionProtectorListResultPage(cur ManagedInstanceEncryptionProtectorListResult, getNextPage func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error)) ManagedInstanceEncryptionProtectorListResultPage { + return ManagedInstanceEncryptionProtectorListResultPage{ + fn: getNextPage, + mieplr: cur, } } -// ManagedInstanceLongTermRetentionBackup a long term retention backup for a managed database. -type ManagedInstanceLongTermRetentionBackup struct { - autorest.Response `json:"-"` - // ManagedInstanceLongTermRetentionBackupProperties - Resource properties. - *ManagedInstanceLongTermRetentionBackupProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// ManagedInstanceEncryptionProtectorProperties properties for an encryption protector execution. +type ManagedInstanceEncryptionProtectorProperties struct { + // ServerKeyName - The name of the managed instance key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // AutoRotationEnabled - Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackup. -func (miltrb ManagedInstanceLongTermRetentionBackup) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorProperties. +func (miepp ManagedInstanceEncryptionProtectorProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if miltrb.ManagedInstanceLongTermRetentionBackupProperties != nil { - objectMap["properties"] = miltrb.ManagedInstanceLongTermRetentionBackupProperties + if miepp.ServerKeyName != nil { + objectMap["serverKeyName"] = miepp.ServerKeyName + } + if miepp.ServerKeyType != "" { + objectMap["serverKeyType"] = miepp.ServerKeyType + } + if miepp.AutoRotationEnabled != nil { + objectMap["autoRotationEnabled"] = miepp.AutoRotationEnabled } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionBackup struct. -func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { +// ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (ManagedInstanceEncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { return err } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var managedInstanceLongTermRetentionBackupProperties ManagedInstanceLongTermRetentionBackupProperties - err = json.Unmarshal(*v, &managedInstanceLongTermRetentionBackupProperties) - if err != nil { - return err - } - miltrb.ManagedInstanceLongTermRetentionBackupProperties = &managedInstanceLongTermRetentionBackupProperties - } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (miep ManagedInstanceEncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miep.Response.Response, err = future.GetResult(sender); err == nil && miep.Response.Response.StatusCode != http.StatusNoContent { + miep, err = client.CreateOrUpdateResponder(miep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", miep.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceEncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsRevalidateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceExternalAdministrator properties of a active directory administrator. +type ManagedInstanceExternalAdministrator struct { + // AdministratorType - Type of the sever administrator. Possible values include: 'AdministratorTypeActiveDirectory' + AdministratorType AdministratorType `json:"administratorType,omitempty"` + // PrincipalType - Principal Type of the sever administrator. Possible values include: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeApplication' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // Login - Login name of the server administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the server administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// ManagedInstanceFamilyCapability the managed server family capability. +type ManagedInstanceFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // Sku - READ-ONLY; SKU name. + Sku *string `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]ManagedInstanceVcoresCapability `json:"supportedVcoresValues,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceFamilyCapability. +func (mifc ManagedInstanceFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mifc.Reason != nil { + objectMap["reason"] = mifc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKey a managed instance key. +type ManagedInstanceKey struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceKeyProperties - Resource properties. + *ManagedInstanceKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKey. +func (mik ManagedInstanceKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mik.ManagedInstanceKeyProperties != nil { + objectMap["properties"] = mik.ManagedInstanceKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceKey struct. +func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mik.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceKeyProperties ManagedInstanceKeyProperties + err = json.Unmarshal(*v, &managedInstanceKeyProperties) + if err != nil { + return err + } + mik.ManagedInstanceKeyProperties = &managedInstanceKeyProperties + } case "id": if v != nil { var ID string @@ -16853,7 +18293,7 @@ func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) if err != nil { return err } - miltrb.ID = &ID + mik.ID = &ID } case "name": if v != nil { @@ -16862,7 +18302,7 @@ func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) if err != nil { return err } - miltrb.Name = &name + mik.Name = &name } case "type": if v != nil { @@ -16871,7 +18311,7 @@ func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) if err != nil { return err } - miltrb.Type = &typeVar + mik.Type = &typeVar } } } @@ -16879,34 +18319,32 @@ func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) return nil } -// ManagedInstanceLongTermRetentionBackupListResult a list of long term retention backups for managed -// database(s). -type ManagedInstanceLongTermRetentionBackupListResult struct { +// ManagedInstanceKeyListResult a list of managed instance keys. +type ManagedInstanceKeyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceLongTermRetentionBackup `json:"value,omitempty"` + Value *[]ManagedInstanceKey `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupListResult. -func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceKeyListResult. +func (miklr ManagedInstanceKeyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceLongTermRetentionBackupListResultIterator provides access to a complete listing of -// ManagedInstanceLongTermRetentionBackup values. -type ManagedInstanceLongTermRetentionBackupListResultIterator struct { +// ManagedInstanceKeyListResultIterator provides access to a complete listing of ManagedInstanceKey values. +type ManagedInstanceKeyListResultIterator struct { i int - page ManagedInstanceLongTermRetentionBackupListResultPage + page ManagedInstanceKeyListResultPage } // NextWithContext 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 *ManagedInstanceLongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -16931,68 +18369,67 @@ func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) NextWithCo // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) Next() error { +func (iter *ManagedInstanceKeyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) NotDone() bool { +func (iter ManagedInstanceKeyListResultIterator) 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 ManagedInstanceLongTermRetentionBackupListResultIterator) Response() ManagedInstanceLongTermRetentionBackupListResult { +func (iter ManagedInstanceKeyListResultIterator) Response() ManagedInstanceKeyListResult { 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 ManagedInstanceLongTermRetentionBackupListResultIterator) Value() ManagedInstanceLongTermRetentionBackup { +func (iter ManagedInstanceKeyListResultIterator) Value() ManagedInstanceKey { if !iter.page.NotDone() { - return ManagedInstanceLongTermRetentionBackup{} + return ManagedInstanceKey{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultIterator type. -func NewManagedInstanceLongTermRetentionBackupListResultIterator(page ManagedInstanceLongTermRetentionBackupListResultPage) ManagedInstanceLongTermRetentionBackupListResultIterator { - return ManagedInstanceLongTermRetentionBackupListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceKeyListResultIterator type. +func NewManagedInstanceKeyListResultIterator(page ManagedInstanceKeyListResultPage) ManagedInstanceKeyListResultIterator { + return ManagedInstanceKeyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) IsEmpty() bool { - return miltrblr.Value == nil || len(*miltrblr.Value) == 0 +func (miklr ManagedInstanceKeyListResult) IsEmpty() bool { + return miklr.Value == nil || len(*miklr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) hasNextLink() bool { - return miltrblr.NextLink != nil && len(*miltrblr.NextLink) != 0 +func (miklr ManagedInstanceKeyListResult) hasNextLink() bool { + return miklr.NextLink != nil && len(*miklr.NextLink) != 0 } -// managedInstanceLongTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceKeyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) managedInstanceLongTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { - if !miltrblr.hasNextLink() { +func (miklr ManagedInstanceKeyListResult) managedInstanceKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miklr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(miltrblr.NextLink))) + autorest.WithBaseURL(to.String(miklr.NextLink))) } -// ManagedInstanceLongTermRetentionBackupListResultPage contains a page of -// ManagedInstanceLongTermRetentionBackup values. -type ManagedInstanceLongTermRetentionBackupListResultPage struct { - fn func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error) - miltrblr ManagedInstanceLongTermRetentionBackupListResult +// ManagedInstanceKeyListResultPage contains a page of ManagedInstanceKey values. +type ManagedInstanceKeyListResultPage struct { + fn func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error) + miklr ManagedInstanceKeyListResult } // NextWithContext 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 *ManagedInstanceLongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -17002,11 +18439,11 @@ func (page *ManagedInstanceLongTermRetentionBackupListResultPage) NextWithContex }() } for { - next, err := page.fn(ctx, page.miltrblr) + next, err := page.fn(ctx, page.miklr) if err != nil { return err } - page.miltrblr = next + page.miklr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -17017,71 +18454,73 @@ func (page *ManagedInstanceLongTermRetentionBackupListResultPage) NextWithContex // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceLongTermRetentionBackupListResultPage) Next() error { +func (page *ManagedInstanceKeyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceLongTermRetentionBackupListResultPage) NotDone() bool { - return !page.miltrblr.IsEmpty() +func (page ManagedInstanceKeyListResultPage) NotDone() bool { + return !page.miklr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceLongTermRetentionBackupListResultPage) Response() ManagedInstanceLongTermRetentionBackupListResult { - return page.miltrblr +func (page ManagedInstanceKeyListResultPage) Response() ManagedInstanceKeyListResult { + return page.miklr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceLongTermRetentionBackupListResultPage) Values() []ManagedInstanceLongTermRetentionBackup { - if page.miltrblr.IsEmpty() { +func (page ManagedInstanceKeyListResultPage) Values() []ManagedInstanceKey { + if page.miklr.IsEmpty() { return nil } - return *page.miltrblr.Value + return *page.miklr.Value } -// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultPage type. -func NewManagedInstanceLongTermRetentionBackupListResultPage(cur ManagedInstanceLongTermRetentionBackupListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error)) ManagedInstanceLongTermRetentionBackupListResultPage { - return ManagedInstanceLongTermRetentionBackupListResultPage{ - fn: getNextPage, - miltrblr: cur, - } +// Creates a new instance of the ManagedInstanceKeyListResultPage type. +func NewManagedInstanceKeyListResultPage(cur ManagedInstanceKeyListResult, getNextPage func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error)) ManagedInstanceKeyListResultPage { + return ManagedInstanceKeyListResultPage{ + fn: getNextPage, + miklr: cur, + } } -// ManagedInstanceLongTermRetentionBackupProperties properties of a long term retention backup -type ManagedInstanceLongTermRetentionBackupProperties struct { - // ManagedInstanceName - READ-ONLY; The managed instance that the backup database belongs to. - ManagedInstanceName *string `json:"managedInstanceName,omitempty"` - // ManagedInstanceCreateTime - READ-ONLY; The create time of the instance. - ManagedInstanceCreateTime *date.Time `json:"managedInstanceCreateTime,omitempty"` - // DatabaseName - READ-ONLY; The name of the database the backup belong to - DatabaseName *string `json:"databaseName,omitempty"` - // DatabaseDeletionTime - READ-ONLY; The delete time of the database - DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` - // BackupTime - READ-ONLY; The time the backup was taken - BackupTime *date.Time `json:"backupTime,omitempty"` - // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. - BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` - // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' - BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` +// ManagedInstanceKeyProperties properties for a key execution. +type ManagedInstanceKeyProperties struct { + // ServerKeyType - The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - READ-ONLY; The key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` + // AutoRotationEnabled - READ-ONLY; Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupProperties. -func (miltrbp ManagedInstanceLongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceKeyProperties. +func (mikp ManagedInstanceKeyProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + if mikp.ServerKeyType != "" { + objectMap["serverKeyType"] = mikp.ServerKeyType + } + if mikp.URI != nil { + objectMap["uri"] = mikp.URI + } return json.Marshal(objectMap) } -// ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture struct { +// ManagedInstanceKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstanceLongTermRetentionPoliciesClient) (ManagedInstanceLongTermRetentionPolicy, error) + Result func(ManagedInstanceKeysClient) (ManagedInstanceKey, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedInstanceKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -17091,129 +18530,92 @@ func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) Unma return nil } -// result is the default implementation for ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture.Result. -func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedInstanceLongTermRetentionPoliciesClient) (miltrp ManagedInstanceLongTermRetentionPolicy, err error) { +// result is the default implementation for ManagedInstanceKeysCreateOrUpdateFuture.Result. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) result(client ManagedInstanceKeysClient) (mik ManagedInstanceKey, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - miltrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture") + mik.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if miltrp.Response.Response, err = future.GetResult(sender); err == nil && miltrp.Response.Response.StatusCode != http.StatusNoContent { - miltrp, err = client.CreateOrUpdateResponder(miltrp.Response.Response) + if mik.Response.Response, err = future.GetResult(sender); err == nil && mik.Response.Response.StatusCode != http.StatusNoContent { + mik, err = client.CreateOrUpdateResponder(mik.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", miltrp.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", mik.Response.Response, "Failure responding to request") } } return } -// ManagedInstanceLongTermRetentionPolicy a long term retention policy. -type ManagedInstanceLongTermRetentionPolicy struct { - autorest.Response `json:"-"` - // BaseLongTermRetentionPolicyProperties - Resource properties. - *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` +// ManagedInstanceKeysDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (autorest.Response, error) } -// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicy. -func (miltrp ManagedInstanceLongTermRetentionPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if miltrp.BaseLongTermRetentionPolicyProperties != nil { - objectMap["properties"] = miltrp.BaseLongTermRetentionPolicyProperties +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - return json.Marshal(objectMap) + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionPolicy struct. -func (miltrp *ManagedInstanceLongTermRetentionPolicy) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) +// result is the default implementation for ManagedInstanceKeysDeleteFuture.Result. +func (future *ManagedInstanceKeysDeleteFuture) result(client ManagedInstanceKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) if err != nil { - return err + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties - err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) - if err != nil { - return err - } - miltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - miltrp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - miltrp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - miltrp.Type = &typeVar - } - } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysDeleteFuture") + return } - - return nil + ar.Response = future.Response() + return } -// ManagedInstanceLongTermRetentionPolicyListResult a list of long term retention policies. -type ManagedInstanceLongTermRetentionPolicyListResult struct { +// ManagedInstanceListResult a list of managed instances. +type ManagedInstanceListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceLongTermRetentionPolicy `json:"value,omitempty"` + Value *[]ManagedInstance `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicyListResult. -func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceListResult. +func (milr ManagedInstanceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceLongTermRetentionPolicyListResultIterator provides access to a complete listing of -// ManagedInstanceLongTermRetentionPolicy values. -type ManagedInstanceLongTermRetentionPolicyListResultIterator struct { +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { i int - page ManagedInstanceLongTermRetentionPolicyListResultPage + page ManagedInstanceListResultPage } // NextWithContext 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 *ManagedInstanceLongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -17238,68 +18640,67 @@ func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) NextWithCo // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) Next() error { +func (iter *ManagedInstanceListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) NotDone() bool { +func (iter ManagedInstanceListResultIterator) 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 ManagedInstanceLongTermRetentionPolicyListResultIterator) Response() ManagedInstanceLongTermRetentionPolicyListResult { +func (iter ManagedInstanceListResultIterator) Response() ManagedInstanceListResult { 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 ManagedInstanceLongTermRetentionPolicyListResultIterator) Value() ManagedInstanceLongTermRetentionPolicy { +func (iter ManagedInstanceListResultIterator) Value() ManagedInstance { if !iter.page.NotDone() { - return ManagedInstanceLongTermRetentionPolicy{} + return ManagedInstance{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultIterator type. -func NewManagedInstanceLongTermRetentionPolicyListResultIterator(page ManagedInstanceLongTermRetentionPolicyListResultPage) ManagedInstanceLongTermRetentionPolicyListResultIterator { - return ManagedInstanceLongTermRetentionPolicyListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceListResultIterator type. +func NewManagedInstanceListResultIterator(page ManagedInstanceListResultPage) ManagedInstanceListResultIterator { + return ManagedInstanceListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) IsEmpty() bool { - return miltrplr.Value == nil || len(*miltrplr.Value) == 0 +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) hasNextLink() bool { - return miltrplr.NextLink != nil && len(*miltrplr.NextLink) != 0 +func (milr ManagedInstanceListResult) hasNextLink() bool { + return milr.NextLink != nil && len(*milr.NextLink) != 0 } -// managedInstanceLongTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) managedInstanceLongTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { - if !miltrplr.hasNextLink() { +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !milr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(miltrplr.NextLink))) + autorest.WithBaseURL(to.String(milr.NextLink))) } -// ManagedInstanceLongTermRetentionPolicyListResultPage contains a page of -// ManagedInstanceLongTermRetentionPolicy values. -type ManagedInstanceLongTermRetentionPolicyListResultPage struct { - fn func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error) - miltrplr ManagedInstanceLongTermRetentionPolicyListResult +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult } // NextWithContext 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 *ManagedInstanceLongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -17309,11 +18710,11 @@ func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) NextWithContex }() } for { - next, err := page.fn(ctx, page.miltrplr) + next, err := page.fn(ctx, page.milr) if err != nil { return err } - page.miltrplr = next + page.milr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -17324,60 +18725,41 @@ func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) NextWithContex // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) Next() error { +func (page *ManagedInstanceListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceLongTermRetentionPolicyListResultPage) NotDone() bool { - return !page.miltrplr.IsEmpty() +func (page ManagedInstanceListResultPage) NotDone() bool { + return !page.milr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Response() ManagedInstanceLongTermRetentionPolicyListResult { - return page.miltrplr +func (page ManagedInstanceListResultPage) Response() ManagedInstanceListResult { + return page.milr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Values() []ManagedInstanceLongTermRetentionPolicy { - if page.miltrplr.IsEmpty() { +func (page ManagedInstanceListResultPage) Values() []ManagedInstance { + if page.milr.IsEmpty() { return nil } - return *page.miltrplr.Value + return *page.milr.Value } -// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultPage type. -func NewManagedInstanceLongTermRetentionPolicyListResultPage(cur ManagedInstanceLongTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error)) ManagedInstanceLongTermRetentionPolicyListResultPage { - return ManagedInstanceLongTermRetentionPolicyListResultPage{ - fn: getNextPage, - miltrplr: cur, +// Creates a new instance of the ManagedInstanceListResultPage type. +func NewManagedInstanceListResultPage(cur ManagedInstanceListResult, getNextPage func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error)) ManagedInstanceListResultPage { + return ManagedInstanceListResultPage{ + fn: getNextPage, + milr: cur, } } -// ManagedInstanceMaintenanceConfigurationCapability the maintenance configuration capability -type ManagedInstanceMaintenanceConfigurationCapability struct { - // Name - READ-ONLY; Maintenance configuration name - Name *string `json:"name,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceMaintenanceConfigurationCapability. -func (mimcc ManagedInstanceMaintenanceConfigurationCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mimcc.Reason != nil { - objectMap["reason"] = mimcc.Reason - } - return json.Marshal(objectMap) -} - -// ManagedInstanceOperation a managed instance operation. -type ManagedInstanceOperation struct { +// ManagedInstanceLongTermRetentionBackup a long term retention backup for a managed database. +type ManagedInstanceLongTermRetentionBackup struct { autorest.Response `json:"-"` - // ManagedInstanceOperationProperties - Resource properties. - *ManagedInstanceOperationProperties `json:"properties,omitempty"` + // ManagedInstanceLongTermRetentionBackupProperties - Resource properties. + *ManagedInstanceLongTermRetentionBackupProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -17386,17 +18768,17 @@ type ManagedInstanceOperation struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceOperation. -func (mio ManagedInstanceOperation) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackup. +func (miltrb ManagedInstanceLongTermRetentionBackup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mio.ManagedInstanceOperationProperties != nil { - objectMap["properties"] = mio.ManagedInstanceOperationProperties + if miltrb.ManagedInstanceLongTermRetentionBackupProperties != nil { + objectMap["properties"] = miltrb.ManagedInstanceLongTermRetentionBackupProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceOperation struct. -func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionBackup struct. +func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -17406,12 +18788,12 @@ func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var managedInstanceOperationProperties ManagedInstanceOperationProperties - err = json.Unmarshal(*v, &managedInstanceOperationProperties) + var managedInstanceLongTermRetentionBackupProperties ManagedInstanceLongTermRetentionBackupProperties + err = json.Unmarshal(*v, &managedInstanceLongTermRetentionBackupProperties) if err != nil { return err } - mio.ManagedInstanceOperationProperties = &managedInstanceOperationProperties + miltrb.ManagedInstanceLongTermRetentionBackupProperties = &managedInstanceLongTermRetentionBackupProperties } case "id": if v != nil { @@ -17420,7 +18802,7 @@ func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { if err != nil { return err } - mio.ID = &ID + miltrb.ID = &ID } case "name": if v != nil { @@ -17429,7 +18811,7 @@ func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { if err != nil { return err } - mio.Name = &name + miltrb.Name = &name } case "type": if v != nil { @@ -17438,7 +18820,7 @@ func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { if err != nil { return err } - mio.Type = &typeVar + miltrb.Type = &typeVar } } } @@ -17446,33 +18828,34 @@ func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { return nil } -// ManagedInstanceOperationListResult the response to a list managed instance operations request -type ManagedInstanceOperationListResult struct { +// ManagedInstanceLongTermRetentionBackupListResult a list of long term retention backups for managed +// database(s). +type ManagedInstanceLongTermRetentionBackupListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceOperation `json:"value,omitempty"` + Value *[]ManagedInstanceLongTermRetentionBackup `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceOperationListResult. -func (miolr ManagedInstanceOperationListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupListResult. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceOperationListResultIterator provides access to a complete listing of -// ManagedInstanceOperation values. -type ManagedInstanceOperationListResultIterator struct { +// ManagedInstanceLongTermRetentionBackupListResultIterator provides access to a complete listing of +// ManagedInstanceLongTermRetentionBackup values. +type ManagedInstanceLongTermRetentionBackupListResultIterator struct { i int - page ManagedInstanceOperationListResultPage + page ManagedInstanceLongTermRetentionBackupListResultPage } // NextWithContext 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 *ManagedInstanceOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -17497,67 +18880,68 @@ func (iter *ManagedInstanceOperationListResultIterator) NextWithContext(ctx cont // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceOperationListResultIterator) Next() error { +func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceOperationListResultIterator) NotDone() bool { +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) 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 ManagedInstanceOperationListResultIterator) Response() ManagedInstanceOperationListResult { +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) Response() ManagedInstanceLongTermRetentionBackupListResult { 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 ManagedInstanceOperationListResultIterator) Value() ManagedInstanceOperation { +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) Value() ManagedInstanceLongTermRetentionBackup { if !iter.page.NotDone() { - return ManagedInstanceOperation{} + return ManagedInstanceLongTermRetentionBackup{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceOperationListResultIterator type. -func NewManagedInstanceOperationListResultIterator(page ManagedInstanceOperationListResultPage) ManagedInstanceOperationListResultIterator { - return ManagedInstanceOperationListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultIterator type. +func NewManagedInstanceLongTermRetentionBackupListResultIterator(page ManagedInstanceLongTermRetentionBackupListResultPage) ManagedInstanceLongTermRetentionBackupListResultIterator { + return ManagedInstanceLongTermRetentionBackupListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (miolr ManagedInstanceOperationListResult) IsEmpty() bool { - return miolr.Value == nil || len(*miolr.Value) == 0 +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) IsEmpty() bool { + return miltrblr.Value == nil || len(*miltrblr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (miolr ManagedInstanceOperationListResult) hasNextLink() bool { - return miolr.NextLink != nil && len(*miolr.NextLink) != 0 +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) hasNextLink() bool { + return miltrblr.NextLink != nil && len(*miltrblr.NextLink) != 0 } -// managedInstanceOperationListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceLongTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (miolr ManagedInstanceOperationListResult) managedInstanceOperationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !miolr.hasNextLink() { +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) managedInstanceLongTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miltrblr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(miolr.NextLink))) + autorest.WithBaseURL(to.String(miltrblr.NextLink))) } -// ManagedInstanceOperationListResultPage contains a page of ManagedInstanceOperation values. -type ManagedInstanceOperationListResultPage struct { - fn func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error) - miolr ManagedInstanceOperationListResult +// ManagedInstanceLongTermRetentionBackupListResultPage contains a page of +// ManagedInstanceLongTermRetentionBackup values. +type ManagedInstanceLongTermRetentionBackupListResultPage struct { + fn func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error) + miltrblr ManagedInstanceLongTermRetentionBackupListResult } // NextWithContext 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 *ManagedInstanceOperationListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceLongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -17567,11 +18951,11 @@ func (page *ManagedInstanceOperationListResultPage) NextWithContext(ctx context. }() } for { - next, err := page.fn(ctx, page.miolr) + next, err := page.fn(ctx, page.miltrblr) if err != nil { return err } - page.miolr = next + page.miltrblr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -17582,133 +18966,108 @@ func (page *ManagedInstanceOperationListResultPage) NextWithContext(ctx context. // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceOperationListResultPage) Next() error { +func (page *ManagedInstanceLongTermRetentionBackupListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceOperationListResultPage) NotDone() bool { - return !page.miolr.IsEmpty() +func (page ManagedInstanceLongTermRetentionBackupListResultPage) NotDone() bool { + return !page.miltrblr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceOperationListResultPage) Response() ManagedInstanceOperationListResult { - return page.miolr +func (page ManagedInstanceLongTermRetentionBackupListResultPage) Response() ManagedInstanceLongTermRetentionBackupListResult { + return page.miltrblr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceOperationListResultPage) Values() []ManagedInstanceOperation { - if page.miolr.IsEmpty() { +func (page ManagedInstanceLongTermRetentionBackupListResultPage) Values() []ManagedInstanceLongTermRetentionBackup { + if page.miltrblr.IsEmpty() { return nil } - return *page.miolr.Value + return *page.miltrblr.Value } -// Creates a new instance of the ManagedInstanceOperationListResultPage type. -func NewManagedInstanceOperationListResultPage(cur ManagedInstanceOperationListResult, getNextPage func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error)) ManagedInstanceOperationListResultPage { - return ManagedInstanceOperationListResultPage{ - fn: getNextPage, - miolr: cur, +// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultPage type. +func NewManagedInstanceLongTermRetentionBackupListResultPage(cur ManagedInstanceLongTermRetentionBackupListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error)) ManagedInstanceLongTermRetentionBackupListResultPage { + return ManagedInstanceLongTermRetentionBackupListResultPage{ + fn: getNextPage, + miltrblr: cur, } } -// ManagedInstanceOperationParametersPair the parameters of a managed instance operation. -type ManagedInstanceOperationParametersPair struct { - // CurrentParameters - READ-ONLY; The current parameters. - CurrentParameters *UpsertManagedServerOperationParameters `json:"currentParameters,omitempty"` - // RequestedParameters - READ-ONLY; The requested parameters. - RequestedParameters *UpsertManagedServerOperationParameters `json:"requestedParameters,omitempty"` +// ManagedInstanceLongTermRetentionBackupProperties properties of a long term retention backup +type ManagedInstanceLongTermRetentionBackupProperties struct { + // ManagedInstanceName - READ-ONLY; The managed instance that the backup database belongs to. + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + // ManagedInstanceCreateTime - READ-ONLY; The create time of the instance. + ManagedInstanceCreateTime *date.Time `json:"managedInstanceCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceOperationParametersPair. -func (miopp ManagedInstanceOperationParametersPair) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupProperties. +func (miltrbp ManagedInstanceLongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceOperationProperties the properties of a managed instance operation. -type ManagedInstanceOperationProperties struct { - // ManagedInstanceName - READ-ONLY; The name of the managed instance the operation is being performed on. - ManagedInstanceName *string `json:"managedInstanceName,omitempty"` - // Operation - READ-ONLY; The name of operation. - Operation *string `json:"operation,omitempty"` - // OperationFriendlyName - READ-ONLY; The friendly name of operation. - OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` - // PercentComplete - READ-ONLY; The percentage of the operation completed. - PercentComplete *int32 `json:"percentComplete,omitempty"` - // StartTime - READ-ONLY; The operation start time. - StartTime *date.Time `json:"startTime,omitempty"` - // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' - State ManagementOperationState `json:"state,omitempty"` - // ErrorCode - READ-ONLY; The operation error code. - ErrorCode *int32 `json:"errorCode,omitempty"` - // ErrorDescription - READ-ONLY; The operation error description. - ErrorDescription *string `json:"errorDescription,omitempty"` - // ErrorSeverity - READ-ONLY; The operation error severity. - ErrorSeverity *int32 `json:"errorSeverity,omitempty"` - // IsUserError - READ-ONLY; Whether or not the error is a user error. - IsUserError *bool `json:"isUserError,omitempty"` - // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. - EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` - // Description - READ-ONLY; The operation description. - Description *string `json:"description,omitempty"` - // IsCancellable - READ-ONLY; Whether the operation can be cancelled. - IsCancellable *bool `json:"isCancellable,omitempty"` - // OperationParameters - READ-ONLY; The operation parameters. - OperationParameters *ManagedInstanceOperationParametersPair `json:"operationParameters,omitempty"` - // OperationSteps - READ-ONLY; The operation steps. - OperationSteps *ManagedInstanceOperationSteps `json:"operationSteps,omitempty"` +// ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceLongTermRetentionPoliciesClient) (ManagedInstanceLongTermRetentionPolicy, error) } -// MarshalJSON is the custom marshaler for ManagedInstanceOperationProperties. -func (miop ManagedInstanceOperationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// ManagedInstanceOperationSteps the steps of a managed instance operation. -type ManagedInstanceOperationSteps struct { - // TotalSteps - READ-ONLY; The total number of operation steps. - TotalSteps *string `json:"totalSteps,omitempty"` - // CurrentStep - READ-ONLY; The number of current operation steps. - CurrentStep *int32 `json:"currentStep,omitempty"` - // StepsList - READ-ONLY; The operation steps list. - StepsList *[]UpsertManagedServerOperationStep `json:"stepsList,omitempty"` +// result is the default implementation for ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedInstanceLongTermRetentionPoliciesClient) (miltrp ManagedInstanceLongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miltrp.Response.Response, err = future.GetResult(sender); err == nil && miltrp.Response.Response.StatusCode != http.StatusNoContent { + miltrp, err = client.CreateOrUpdateResponder(miltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", miltrp.Response.Response, "Failure responding to request") + } + } + return } -// MarshalJSON is the custom marshaler for ManagedInstanceOperationSteps. -func (mios ManagedInstanceOperationSteps) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ManagedInstancePairInfo pairs of Managed Instances in the failover group. -type ManagedInstancePairInfo struct { - // PrimaryManagedInstanceID - Id of Primary Managed Instance in pair. - PrimaryManagedInstanceID *string `json:"primaryManagedInstanceId,omitempty"` - // PartnerManagedInstanceID - Id of Partner Managed Instance in pair. - PartnerManagedInstanceID *string `json:"partnerManagedInstanceId,omitempty"` -} - -// ManagedInstancePecProperty a private endpoint connection under a managed instance -type ManagedInstancePecProperty struct { - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Properties - READ-ONLY; Private endpoint connection properties - Properties *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstancePecProperty. -func (mipp ManagedInstancePecProperty) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ManagedInstancePrivateEndpointConnection a private endpoint connection -type ManagedInstancePrivateEndpointConnection struct { +// ManagedInstanceLongTermRetentionPolicy a long term retention policy. +type ManagedInstanceLongTermRetentionPolicy struct { autorest.Response `json:"-"` - // ManagedInstancePrivateEndpointConnectionProperties - Resource properties. - *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` + // BaseLongTermRetentionPolicyProperties - Resource properties. + *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -17717,17 +19076,17 @@ type ManagedInstancePrivateEndpointConnection struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnection. -func (mipec ManagedInstancePrivateEndpointConnection) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicy. +func (miltrp ManagedInstanceLongTermRetentionPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mipec.ManagedInstancePrivateEndpointConnectionProperties != nil { - objectMap["properties"] = mipec.ManagedInstancePrivateEndpointConnectionProperties + if miltrp.BaseLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = miltrp.BaseLongTermRetentionPolicyProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstancePrivateEndpointConnection struct. -func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionPolicy struct. +func (miltrp *ManagedInstanceLongTermRetentionPolicy) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -17737,12 +19096,12 @@ func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte switch k { case "properties": if v != nil { - var managedInstancePrivateEndpointConnectionProperties ManagedInstancePrivateEndpointConnectionProperties - err = json.Unmarshal(*v, &managedInstancePrivateEndpointConnectionProperties) + var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) if err != nil { return err } - mipec.ManagedInstancePrivateEndpointConnectionProperties = &managedInstancePrivateEndpointConnectionProperties + miltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties } case "id": if v != nil { @@ -17751,7 +19110,7 @@ func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte if err != nil { return err } - mipec.ID = &ID + miltrp.ID = &ID } case "name": if v != nil { @@ -17760,7 +19119,7 @@ func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte if err != nil { return err } - mipec.Name = &name + miltrp.Name = &name } case "type": if v != nil { @@ -17769,7 +19128,7 @@ func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte if err != nil { return err } - mipec.Type = &typeVar + miltrp.Type = &typeVar } } } @@ -17777,33 +19136,33 @@ func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte return nil } -// ManagedInstancePrivateEndpointConnectionListResult a list of private endpoint connections. -type ManagedInstancePrivateEndpointConnectionListResult struct { +// ManagedInstanceLongTermRetentionPolicyListResult a list of long term retention policies. +type ManagedInstanceLongTermRetentionPolicyListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstancePrivateEndpointConnection `json:"value,omitempty"` + Value *[]ManagedInstanceLongTermRetentionPolicy `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionListResult. -func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicyListResult. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstancePrivateEndpointConnectionListResultIterator provides access to a complete listing of -// ManagedInstancePrivateEndpointConnection values. -type ManagedInstancePrivateEndpointConnectionListResultIterator struct { +// ManagedInstanceLongTermRetentionPolicyListResultIterator provides access to a complete listing of +// ManagedInstanceLongTermRetentionPolicy values. +type ManagedInstanceLongTermRetentionPolicyListResultIterator struct { i int - page ManagedInstancePrivateEndpointConnectionListResultPage + page ManagedInstanceLongTermRetentionPolicyListResultPage } // NextWithContext 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 *ManagedInstancePrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -17828,68 +19187,68 @@ func (iter *ManagedInstancePrivateEndpointConnectionListResultIterator) NextWith // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstancePrivateEndpointConnectionListResultIterator) Next() error { +func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstancePrivateEndpointConnectionListResultIterator) NotDone() bool { +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) 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 ManagedInstancePrivateEndpointConnectionListResultIterator) Response() ManagedInstancePrivateEndpointConnectionListResult { +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) Response() ManagedInstanceLongTermRetentionPolicyListResult { 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 ManagedInstancePrivateEndpointConnectionListResultIterator) Value() ManagedInstancePrivateEndpointConnection { +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) Value() ManagedInstanceLongTermRetentionPolicy { if !iter.page.NotDone() { - return ManagedInstancePrivateEndpointConnection{} + return ManagedInstanceLongTermRetentionPolicy{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstancePrivateEndpointConnectionListResultIterator type. -func NewManagedInstancePrivateEndpointConnectionListResultIterator(page ManagedInstancePrivateEndpointConnectionListResultPage) ManagedInstancePrivateEndpointConnectionListResultIterator { - return ManagedInstancePrivateEndpointConnectionListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultIterator type. +func NewManagedInstanceLongTermRetentionPolicyListResultIterator(page ManagedInstanceLongTermRetentionPolicyListResultPage) ManagedInstanceLongTermRetentionPolicyListResultIterator { + return ManagedInstanceLongTermRetentionPolicyListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) IsEmpty() bool { - return mipeclr.Value == nil || len(*mipeclr.Value) == 0 +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) IsEmpty() bool { + return miltrplr.Value == nil || len(*miltrplr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) hasNextLink() bool { - return mipeclr.NextLink != nil && len(*mipeclr.NextLink) != 0 +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) hasNextLink() bool { + return miltrplr.NextLink != nil && len(*miltrplr.NextLink) != 0 } -// managedInstancePrivateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceLongTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) managedInstancePrivateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mipeclr.hasNextLink() { +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) managedInstanceLongTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miltrplr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mipeclr.NextLink))) + autorest.WithBaseURL(to.String(miltrplr.NextLink))) } -// ManagedInstancePrivateEndpointConnectionListResultPage contains a page of -// ManagedInstancePrivateEndpointConnection values. -type ManagedInstancePrivateEndpointConnectionListResultPage struct { - fn func(context.Context, ManagedInstancePrivateEndpointConnectionListResult) (ManagedInstancePrivateEndpointConnectionListResult, error) - mipeclr ManagedInstancePrivateEndpointConnectionListResult +// ManagedInstanceLongTermRetentionPolicyListResultPage contains a page of +// ManagedInstanceLongTermRetentionPolicy values. +type ManagedInstanceLongTermRetentionPolicyListResultPage struct { + fn func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error) + miltrplr ManagedInstanceLongTermRetentionPolicyListResult } // NextWithContext 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 *ManagedInstancePrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -17899,11 +19258,11 @@ func (page *ManagedInstancePrivateEndpointConnectionListResultPage) NextWithCont }() } for { - next, err := page.fn(ctx, page.mipeclr) + next, err := page.fn(ctx, page.miltrplr) if err != nil { return err } - page.mipeclr = next + page.miltrplr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -17914,190 +19273,155 @@ func (page *ManagedInstancePrivateEndpointConnectionListResultPage) NextWithCont // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstancePrivateEndpointConnectionListResultPage) Next() error { +func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstancePrivateEndpointConnectionListResultPage) NotDone() bool { - return !page.mipeclr.IsEmpty() +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) NotDone() bool { + return !page.miltrplr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstancePrivateEndpointConnectionListResultPage) Response() ManagedInstancePrivateEndpointConnectionListResult { - return page.mipeclr +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Response() ManagedInstanceLongTermRetentionPolicyListResult { + return page.miltrplr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstancePrivateEndpointConnectionListResultPage) Values() []ManagedInstancePrivateEndpointConnection { - if page.mipeclr.IsEmpty() { +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Values() []ManagedInstanceLongTermRetentionPolicy { + if page.miltrplr.IsEmpty() { return nil } - return *page.mipeclr.Value + return *page.miltrplr.Value } -// Creates a new instance of the ManagedInstancePrivateEndpointConnectionListResultPage type. -func NewManagedInstancePrivateEndpointConnectionListResultPage(cur ManagedInstancePrivateEndpointConnectionListResult, getNextPage func(context.Context, ManagedInstancePrivateEndpointConnectionListResult) (ManagedInstancePrivateEndpointConnectionListResult, error)) ManagedInstancePrivateEndpointConnectionListResultPage { - return ManagedInstancePrivateEndpointConnectionListResultPage{ - fn: getNextPage, - mipeclr: cur, +// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultPage type. +func NewManagedInstanceLongTermRetentionPolicyListResultPage(cur ManagedInstanceLongTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error)) ManagedInstanceLongTermRetentionPolicyListResultPage { + return ManagedInstanceLongTermRetentionPolicyListResultPage{ + fn: getNextPage, + miltrplr: cur, } } -// ManagedInstancePrivateEndpointConnectionProperties properties of a private endpoint connection. -type ManagedInstancePrivateEndpointConnectionProperties struct { - // PrivateEndpoint - Private endpoint which the connection belongs to. - PrivateEndpoint *ManagedInstancePrivateEndpointProperty `json:"privateEndpoint,omitempty"` - // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. - PrivateLinkServiceConnectionState *ManagedInstancePrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` - // ProvisioningState - READ-ONLY; State of the Private Endpoint Connection. - ProvisioningState *string `json:"provisioningState,omitempty"` +// ManagedInstanceMaintenanceConfigurationCapability the maintenance configuration capability +type ManagedInstanceMaintenanceConfigurationCapability struct { + // Name - READ-ONLY; Maintenance configuration name + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionProperties. -func (mipecp ManagedInstancePrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceMaintenanceConfigurationCapability. +func (mimcc ManagedInstanceMaintenanceConfigurationCapability) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if mipecp.PrivateEndpoint != nil { - objectMap["privateEndpoint"] = mipecp.PrivateEndpoint - } - if mipecp.PrivateLinkServiceConnectionState != nil { - objectMap["privateLinkServiceConnectionState"] = mipecp.PrivateLinkServiceConnectionState + if mimcc.Reason != nil { + objectMap["reason"] = mimcc.Reason } return json.Marshal(objectMap) } -// ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstancePrivateEndpointConnectionsClient) (ManagedInstancePrivateEndpointConnection, error) +// ManagedInstanceOperation a managed instance operation. +type ManagedInstanceOperation struct { + autorest.Response `json:"-"` + // ManagedInstanceOperationProperties - Resource properties. + *ManagedInstanceOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// MarshalJSON is the custom marshaler for ManagedInstanceOperation. +func (mio ManagedInstanceOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mio.ManagedInstanceOperationProperties != nil { + objectMap["properties"] = mio.ManagedInstanceOperationProperties } - future.FutureAPI = &azFuture - future.Result = future.result - return nil + return json.Marshal(objectMap) } -// result is the default implementation for ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture.Result. -func (future *ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture) result(client ManagedInstancePrivateEndpointConnectionsClient) (mipec ManagedInstancePrivateEndpointConnection, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceOperation struct. +func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mipec.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mipec.Response.Response, err = future.GetResult(sender); err == nil && mipec.Response.Response.StatusCode != http.StatusNoContent { - mipec, err = client.CreateOrUpdateResponder(mipec.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", mipec.Response.Response, "Failure responding to request") - } - } - return -} - -// ManagedInstancePrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type ManagedInstancePrivateEndpointConnectionsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstancePrivateEndpointConnectionsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstancePrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { return err } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedInstancePrivateEndpointConnectionsDeleteFuture.Result. -func (future *ManagedInstancePrivateEndpointConnectionsDeleteFuture) result(client ManagedInstancePrivateEndpointConnectionsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture") - return + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceOperationProperties ManagedInstanceOperationProperties + err = json.Unmarshal(*v, &managedInstanceOperationProperties) + if err != nil { + return err + } + mio.ManagedInstanceOperationProperties = &managedInstanceOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mio.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mio.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mio.Type = &typeVar + } + } } - ar.Response = future.Response() - return -} - -// ManagedInstancePrivateEndpointProperty ... -type ManagedInstancePrivateEndpointProperty struct { - // ID - Resource id of the private endpoint. - ID *string `json:"id,omitempty"` -} - -// ManagedInstancePrivateLink a private link resource -type ManagedInstancePrivateLink struct { - autorest.Response `json:"-"` - // Properties - READ-ONLY; The private link resource group id. - Properties *ManagedInstancePrivateLinkProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} -// MarshalJSON is the custom marshaler for ManagedInstancePrivateLink. -func (mipl ManagedInstancePrivateLink) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) + return nil } -// ManagedInstancePrivateLinkListResult a list of private link resources -type ManagedInstancePrivateLinkListResult struct { +// ManagedInstanceOperationListResult the response to a list managed instance operations request +type ManagedInstanceOperationListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstancePrivateLink `json:"value,omitempty"` + Value *[]ManagedInstanceOperation `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkListResult. -func (mipllr ManagedInstancePrivateLinkListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceOperationListResult. +func (miolr ManagedInstanceOperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstancePrivateLinkListResultIterator provides access to a complete listing of -// ManagedInstancePrivateLink values. -type ManagedInstancePrivateLinkListResultIterator struct { +// ManagedInstanceOperationListResultIterator provides access to a complete listing of +// ManagedInstanceOperation values. +type ManagedInstanceOperationListResultIterator struct { i int - page ManagedInstancePrivateLinkListResultPage + page ManagedInstanceOperationListResultPage } // NextWithContext 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 *ManagedInstancePrivateLinkListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -18122,67 +19446,67 @@ func (iter *ManagedInstancePrivateLinkListResultIterator) NextWithContext(ctx co // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstancePrivateLinkListResultIterator) Next() error { +func (iter *ManagedInstanceOperationListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstancePrivateLinkListResultIterator) NotDone() bool { +func (iter ManagedInstanceOperationListResultIterator) 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 ManagedInstancePrivateLinkListResultIterator) Response() ManagedInstancePrivateLinkListResult { +func (iter ManagedInstanceOperationListResultIterator) Response() ManagedInstanceOperationListResult { 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 ManagedInstancePrivateLinkListResultIterator) Value() ManagedInstancePrivateLink { +func (iter ManagedInstanceOperationListResultIterator) Value() ManagedInstanceOperation { if !iter.page.NotDone() { - return ManagedInstancePrivateLink{} + return ManagedInstanceOperation{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstancePrivateLinkListResultIterator type. -func NewManagedInstancePrivateLinkListResultIterator(page ManagedInstancePrivateLinkListResultPage) ManagedInstancePrivateLinkListResultIterator { - return ManagedInstancePrivateLinkListResultIterator{page: page} +// Creates a new instance of the ManagedInstanceOperationListResultIterator type. +func NewManagedInstanceOperationListResultIterator(page ManagedInstanceOperationListResultPage) ManagedInstanceOperationListResultIterator { + return ManagedInstanceOperationListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mipllr ManagedInstancePrivateLinkListResult) IsEmpty() bool { - return mipllr.Value == nil || len(*mipllr.Value) == 0 +func (miolr ManagedInstanceOperationListResult) IsEmpty() bool { + return miolr.Value == nil || len(*miolr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mipllr ManagedInstancePrivateLinkListResult) hasNextLink() bool { - return mipllr.NextLink != nil && len(*mipllr.NextLink) != 0 +func (miolr ManagedInstanceOperationListResult) hasNextLink() bool { + return miolr.NextLink != nil && len(*miolr.NextLink) != 0 } -// managedInstancePrivateLinkListResultPreparer prepares a request to retrieve the next set of results. +// managedInstanceOperationListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mipllr ManagedInstancePrivateLinkListResult) managedInstancePrivateLinkListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mipllr.hasNextLink() { +func (miolr ManagedInstanceOperationListResult) managedInstanceOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miolr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mipllr.NextLink))) + autorest.WithBaseURL(to.String(miolr.NextLink))) } -// ManagedInstancePrivateLinkListResultPage contains a page of ManagedInstancePrivateLink values. -type ManagedInstancePrivateLinkListResultPage struct { - fn func(context.Context, ManagedInstancePrivateLinkListResult) (ManagedInstancePrivateLinkListResult, error) - mipllr ManagedInstancePrivateLinkListResult +// ManagedInstanceOperationListResultPage contains a page of ManagedInstanceOperation values. +type ManagedInstanceOperationListResultPage struct { + fn func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error) + miolr ManagedInstanceOperationListResult } // NextWithContext 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 *ManagedInstancePrivateLinkListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceOperationListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -18192,11 +19516,11 @@ func (page *ManagedInstancePrivateLinkListResultPage) NextWithContext(ctx contex }() } for { - next, err := page.fn(ctx, page.mipllr) + next, err := page.fn(ctx, page.miolr) if err != nil { return err } - page.mipllr = next + page.miolr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -18207,88 +19531,713 @@ func (page *ManagedInstancePrivateLinkListResultPage) NextWithContext(ctx contex // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstancePrivateLinkListResultPage) Next() error { +func (page *ManagedInstanceOperationListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstancePrivateLinkListResultPage) NotDone() bool { - return !page.mipllr.IsEmpty() +func (page ManagedInstanceOperationListResultPage) NotDone() bool { + return !page.miolr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstancePrivateLinkListResultPage) Response() ManagedInstancePrivateLinkListResult { - return page.mipllr +func (page ManagedInstanceOperationListResultPage) Response() ManagedInstanceOperationListResult { + return page.miolr } // Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstancePrivateLinkListResultPage) Values() []ManagedInstancePrivateLink { - if page.mipllr.IsEmpty() { +func (page ManagedInstanceOperationListResultPage) Values() []ManagedInstanceOperation { + if page.miolr.IsEmpty() { return nil } - return *page.mipllr.Value + return *page.miolr.Value } -// Creates a new instance of the ManagedInstancePrivateLinkListResultPage type. -func NewManagedInstancePrivateLinkListResultPage(cur ManagedInstancePrivateLinkListResult, getNextPage func(context.Context, ManagedInstancePrivateLinkListResult) (ManagedInstancePrivateLinkListResult, error)) ManagedInstancePrivateLinkListResultPage { - return ManagedInstancePrivateLinkListResultPage{ - fn: getNextPage, - mipllr: cur, +// Creates a new instance of the ManagedInstanceOperationListResultPage type. +func NewManagedInstanceOperationListResultPage(cur ManagedInstanceOperationListResult, getNextPage func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error)) ManagedInstanceOperationListResultPage { + return ManagedInstanceOperationListResultPage{ + fn: getNextPage, + miolr: cur, } } -// ManagedInstancePrivateLinkProperties properties of a private link resource. -type ManagedInstancePrivateLinkProperties struct { - // GroupID - READ-ONLY; The private link resource group id. - GroupID *string `json:"groupId,omitempty"` - // RequiredMembers - READ-ONLY; The private link resource required member names. - RequiredMembers *[]string `json:"requiredMembers,omitempty"` +// ManagedInstanceOperationParametersPair the parameters of a managed instance operation. +type ManagedInstanceOperationParametersPair struct { + // CurrentParameters - READ-ONLY; The current parameters. + CurrentParameters *UpsertManagedServerOperationParameters `json:"currentParameters,omitempty"` + // RequestedParameters - READ-ONLY; The requested parameters. + RequestedParameters *UpsertManagedServerOperationParameters `json:"requestedParameters,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkProperties. -func (miplp ManagedInstancePrivateLinkProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceOperationParametersPair. +func (miopp ManagedInstanceOperationParametersPair) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstancePrivateLinkServiceConnectionStateProperty ... -type ManagedInstancePrivateLinkServiceConnectionStateProperty struct { - // Status - The private link service connection status. - Status *string `json:"status,omitempty"` - // Description - The private link service connection description. +// ManagedInstanceOperationProperties the properties of a managed instance operation. +type ManagedInstanceOperationProperties struct { + // ManagedInstanceName - READ-ONLY; The name of the managed instance the operation is being performed on. + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. Description *string `json:"description,omitempty"` - // ActionsRequired - READ-ONLY; The private link service connection description. - ActionsRequired *string `json:"actionsRequired,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` + // OperationParameters - READ-ONLY; The operation parameters. + OperationParameters *ManagedInstanceOperationParametersPair `json:"operationParameters,omitempty"` + // OperationSteps - READ-ONLY; The operation steps. + OperationSteps *ManagedInstanceOperationSteps `json:"operationSteps,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkServiceConnectionStateProperty. -func (miplscsp ManagedInstancePrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceOperationProperties. +func (miop ManagedInstanceOperationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if miplscsp.Status != nil { - objectMap["status"] = miplscsp.Status - } - if miplscsp.Description != nil { - objectMap["description"] = miplscsp.Description - } return json.Marshal(objectMap) } -// ManagedInstanceProperties the properties of a managed instance. -type ManagedInstanceProperties struct { - // ProvisioningState - READ-ONLY; Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1Deleting', 'ProvisioningState1Updating', 'ProvisioningState1Unknown', 'ProvisioningState1Succeeded', 'ProvisioningState1Failed' - ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` - // ManagedInstanceCreateMode - Specifies the mode of database creation. - // - // Default: Regular instance creation. - // - // Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: 'ManagedServerCreateModeDefault', 'ManagedServerCreateModePointInTimeRestore' - ManagedInstanceCreateMode ManagedServerCreateMode `json:"managedInstanceCreateMode,omitempty"` - // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the managed instance. - FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` - // AdministratorLogin - Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). - AdministratorLogin *string `json:"administratorLogin,omitempty"` - // AdministratorLoginPassword - The administrator login password (required for managed instance creation). - AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` +// ManagedInstanceOperationSteps the steps of a managed instance operation. +type ManagedInstanceOperationSteps struct { + // TotalSteps - READ-ONLY; The total number of operation steps. + TotalSteps *string `json:"totalSteps,omitempty"` + // CurrentStep - READ-ONLY; The number of current operation steps. + CurrentStep *int32 `json:"currentStep,omitempty"` + // StepsList - READ-ONLY; The operation steps list. + StepsList *[]UpsertManagedServerOperationStep `json:"stepsList,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationSteps. +func (mios ManagedInstanceOperationSteps) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePairInfo pairs of Managed Instances in the failover group. +type ManagedInstancePairInfo struct { + // PrimaryManagedInstanceID - Id of Primary Managed Instance in pair. + PrimaryManagedInstanceID *string `json:"primaryManagedInstanceId,omitempty"` + // PartnerManagedInstanceID - Id of Partner Managed Instance in pair. + PartnerManagedInstanceID *string `json:"partnerManagedInstanceId,omitempty"` +} + +// ManagedInstancePecProperty a private endpoint connection under a managed instance +type ManagedInstancePecProperty struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Properties - READ-ONLY; Private endpoint connection properties + Properties *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePecProperty. +func (mipp ManagedInstancePecProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnection a private endpoint connection +type ManagedInstancePrivateEndpointConnection struct { + autorest.Response `json:"-"` + // ManagedInstancePrivateEndpointConnectionProperties - Resource properties. + *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnection. +func (mipec ManagedInstancePrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mipec.ManagedInstancePrivateEndpointConnectionProperties != nil { + objectMap["properties"] = mipec.ManagedInstancePrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstancePrivateEndpointConnection struct. +func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstancePrivateEndpointConnectionProperties ManagedInstancePrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &managedInstancePrivateEndpointConnectionProperties) + if err != nil { + return err + } + mipec.ManagedInstancePrivateEndpointConnectionProperties = &managedInstancePrivateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mipec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mipec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mipec.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstancePrivateEndpointConnectionListResult a list of private endpoint connections. +type ManagedInstancePrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstancePrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionListResult. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnectionListResultIterator provides access to a complete listing of +// ManagedInstancePrivateEndpointConnection values. +type ManagedInstancePrivateEndpointConnectionListResultIterator struct { + i int + page ManagedInstancePrivateEndpointConnectionListResultPage +} + +// NextWithContext 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 *ManagedInstancePrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstancePrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstancePrivateEndpointConnectionListResultIterator) 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 ManagedInstancePrivateEndpointConnectionListResultIterator) Response() ManagedInstancePrivateEndpointConnectionListResult { + 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 ManagedInstancePrivateEndpointConnectionListResultIterator) Value() ManagedInstancePrivateEndpointConnection { + if !iter.page.NotDone() { + return ManagedInstancePrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstancePrivateEndpointConnectionListResultIterator type. +func NewManagedInstancePrivateEndpointConnectionListResultIterator(page ManagedInstancePrivateEndpointConnectionListResultPage) ManagedInstancePrivateEndpointConnectionListResultIterator { + return ManagedInstancePrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) IsEmpty() bool { + return mipeclr.Value == nil || len(*mipeclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) hasNextLink() bool { + return mipeclr.NextLink != nil && len(*mipeclr.NextLink) != 0 +} + +// managedInstancePrivateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) managedInstancePrivateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mipeclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mipeclr.NextLink))) +} + +// ManagedInstancePrivateEndpointConnectionListResultPage contains a page of +// ManagedInstancePrivateEndpointConnection values. +type ManagedInstancePrivateEndpointConnectionListResultPage struct { + fn func(context.Context, ManagedInstancePrivateEndpointConnectionListResult) (ManagedInstancePrivateEndpointConnectionListResult, error) + mipeclr ManagedInstancePrivateEndpointConnectionListResult +} + +// NextWithContext 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 *ManagedInstancePrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mipeclr) + if err != nil { + return err + } + page.mipeclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstancePrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstancePrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.mipeclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstancePrivateEndpointConnectionListResultPage) Response() ManagedInstancePrivateEndpointConnectionListResult { + return page.mipeclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstancePrivateEndpointConnectionListResultPage) Values() []ManagedInstancePrivateEndpointConnection { + if page.mipeclr.IsEmpty() { + return nil + } + return *page.mipeclr.Value +} + +// Creates a new instance of the ManagedInstancePrivateEndpointConnectionListResultPage type. +func NewManagedInstancePrivateEndpointConnectionListResultPage(cur ManagedInstancePrivateEndpointConnectionListResult, getNextPage func(context.Context, ManagedInstancePrivateEndpointConnectionListResult) (ManagedInstancePrivateEndpointConnectionListResult, error)) ManagedInstancePrivateEndpointConnectionListResultPage { + return ManagedInstancePrivateEndpointConnectionListResultPage{ + fn: getNextPage, + mipeclr: cur, + } +} + +// ManagedInstancePrivateEndpointConnectionProperties properties of a private endpoint connection. +type ManagedInstancePrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *ManagedInstancePrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. + PrivateLinkServiceConnectionState *ManagedInstancePrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the Private Endpoint Connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionProperties. +func (mipecp ManagedInstancePrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mipecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = mipecp.PrivateEndpoint + } + if mipecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = mipecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancePrivateEndpointConnectionsClient) (ManagedInstancePrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture) result(client ManagedInstancePrivateEndpointConnectionsClient) (mipec ManagedInstancePrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mipec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mipec.Response.Response, err = future.GetResult(sender); err == nil && mipec.Response.Response.StatusCode != http.StatusNoContent { + mipec, err = client.CreateOrUpdateResponder(mipec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", mipec.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstancePrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstancePrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancePrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancePrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancePrivateEndpointConnectionsDeleteFuture.Result. +func (future *ManagedInstancePrivateEndpointConnectionsDeleteFuture) result(client ManagedInstancePrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancePrivateEndpointProperty ... +type ManagedInstancePrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// ManagedInstancePrivateLink a private link resource +type ManagedInstancePrivateLink struct { + autorest.Response `json:"-"` + // Properties - READ-ONLY; The private link resource group id. + Properties *ManagedInstancePrivateLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLink. +func (mipl ManagedInstancePrivateLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateLinkListResult a list of private link resources +type ManagedInstancePrivateLinkListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstancePrivateLink `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkListResult. +func (mipllr ManagedInstancePrivateLinkListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateLinkListResultIterator provides access to a complete listing of +// ManagedInstancePrivateLink values. +type ManagedInstancePrivateLinkListResultIterator struct { + i int + page ManagedInstancePrivateLinkListResultPage +} + +// NextWithContext 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 *ManagedInstancePrivateLinkListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstancePrivateLinkListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstancePrivateLinkListResultIterator) 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 ManagedInstancePrivateLinkListResultIterator) Response() ManagedInstancePrivateLinkListResult { + 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 ManagedInstancePrivateLinkListResultIterator) Value() ManagedInstancePrivateLink { + if !iter.page.NotDone() { + return ManagedInstancePrivateLink{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstancePrivateLinkListResultIterator type. +func NewManagedInstancePrivateLinkListResultIterator(page ManagedInstancePrivateLinkListResultPage) ManagedInstancePrivateLinkListResultIterator { + return ManagedInstancePrivateLinkListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mipllr ManagedInstancePrivateLinkListResult) IsEmpty() bool { + return mipllr.Value == nil || len(*mipllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mipllr ManagedInstancePrivateLinkListResult) hasNextLink() bool { + return mipllr.NextLink != nil && len(*mipllr.NextLink) != 0 +} + +// managedInstancePrivateLinkListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mipllr ManagedInstancePrivateLinkListResult) managedInstancePrivateLinkListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mipllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mipllr.NextLink))) +} + +// ManagedInstancePrivateLinkListResultPage contains a page of ManagedInstancePrivateLink values. +type ManagedInstancePrivateLinkListResultPage struct { + fn func(context.Context, ManagedInstancePrivateLinkListResult) (ManagedInstancePrivateLinkListResult, error) + mipllr ManagedInstancePrivateLinkListResult +} + +// NextWithContext 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 *ManagedInstancePrivateLinkListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mipllr) + if err != nil { + return err + } + page.mipllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstancePrivateLinkListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstancePrivateLinkListResultPage) NotDone() bool { + return !page.mipllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstancePrivateLinkListResultPage) Response() ManagedInstancePrivateLinkListResult { + return page.mipllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstancePrivateLinkListResultPage) Values() []ManagedInstancePrivateLink { + if page.mipllr.IsEmpty() { + return nil + } + return *page.mipllr.Value +} + +// Creates a new instance of the ManagedInstancePrivateLinkListResultPage type. +func NewManagedInstancePrivateLinkListResultPage(cur ManagedInstancePrivateLinkListResult, getNextPage func(context.Context, ManagedInstancePrivateLinkListResult) (ManagedInstancePrivateLinkListResult, error)) ManagedInstancePrivateLinkListResultPage { + return ManagedInstancePrivateLinkListResultPage{ + fn: getNextPage, + mipllr: cur, + } +} + +// ManagedInstancePrivateLinkProperties properties of a private link resource. +type ManagedInstancePrivateLinkProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkProperties. +func (miplp ManagedInstancePrivateLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateLinkServiceConnectionStateProperty ... +type ManagedInstancePrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The private link service connection description. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkServiceConnectionStateProperty. +func (miplscsp ManagedInstancePrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miplscsp.Status != nil { + objectMap["status"] = miplscsp.Status + } + if miplscsp.Description != nil { + objectMap["description"] = miplscsp.Description + } + return json.Marshal(objectMap) +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // ProvisioningState - READ-ONLY; Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1Deleting', 'ProvisioningState1Updating', 'ProvisioningState1Unknown', 'ProvisioningState1Succeeded', 'ProvisioningState1Failed', 'ProvisioningState1Accepted', 'ProvisioningState1Created', 'ProvisioningState1Deleted', 'ProvisioningState1Unrecognized', 'ProvisioningState1Running', 'ProvisioningState1Canceled', 'ProvisioningState1NotSpecified', 'ProvisioningState1Registering', 'ProvisioningState1TimedOut' + ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` + // ManagedInstanceCreateMode - Specifies the mode of database creation. + // + // Default: Regular instance creation. + // + // Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: 'ManagedServerCreateModeDefault', 'ManagedServerCreateModePointInTimeRestore' + ManagedInstanceCreateMode ManagedServerCreateMode `json:"managedInstanceCreateMode,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the managed instance. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // AdministratorLogin - Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for managed instance creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` // SubnetID - Subnet resource ID for the managed instance. SubnetID *string `json:"subnetId,omitempty"` // State - READ-ONLY; The state of the managed instance. @@ -18328,8 +20277,10 @@ type ManagedInstanceProperties struct { PrivateEndpointConnections *[]ManagedInstancePecProperty `json:"privateEndpointConnections,omitempty"` // MinimalTLSVersion - Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2' MinimalTLSVersion *string `json:"minimalTlsVersion,omitempty"` - // StorageAccountType - The storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). Possible values include: 'StorageAccountTypeGRS', 'StorageAccountTypeLRS', 'StorageAccountTypeZRS' - StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` + // CurrentBackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + CurrentBackupStorageRedundancy BackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage account type to be used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` // ZoneRedundant - Whether or not the multi-az is enabled. ZoneRedundant *bool `json:"zoneRedundant,omitempty"` // PrimaryUserAssignedIdentityID - The resource id of a user assigned identity to be used by default. @@ -18338,85 +20289,660 @@ type ManagedInstanceProperties struct { KeyID *string `json:"keyId,omitempty"` // Administrators - The Azure Active Directory administrator of the server. Administrators *ManagedInstanceExternalAdministrator `json:"administrators,omitempty"` + // ServicePrincipal - The managed instance's service principal. + ServicePrincipal *ServicePrincipal `json:"servicePrincipal,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceProperties. +func (mip ManagedInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mip.ManagedInstanceCreateMode != "" { + objectMap["managedInstanceCreateMode"] = mip.ManagedInstanceCreateMode + } + if mip.AdministratorLogin != nil { + objectMap["administratorLogin"] = mip.AdministratorLogin + } + if mip.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = mip.AdministratorLoginPassword + } + if mip.SubnetID != nil { + objectMap["subnetId"] = mip.SubnetID + } + if mip.LicenseType != "" { + objectMap["licenseType"] = mip.LicenseType + } + if mip.VCores != nil { + objectMap["vCores"] = mip.VCores + } + if mip.StorageSizeInGB != nil { + objectMap["storageSizeInGB"] = mip.StorageSizeInGB + } + if mip.Collation != nil { + objectMap["collation"] = mip.Collation + } + if mip.DNSZonePartner != nil { + objectMap["dnsZonePartner"] = mip.DNSZonePartner + } + if mip.PublicDataEndpointEnabled != nil { + objectMap["publicDataEndpointEnabled"] = mip.PublicDataEndpointEnabled + } + if mip.SourceManagedInstanceID != nil { + objectMap["sourceManagedInstanceId"] = mip.SourceManagedInstanceID + } + if mip.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mip.RestorePointInTime + } + if mip.ProxyOverride != "" { + objectMap["proxyOverride"] = mip.ProxyOverride + } + if mip.TimezoneID != nil { + objectMap["timezoneId"] = mip.TimezoneID + } + if mip.InstancePoolID != nil { + objectMap["instancePoolId"] = mip.InstancePoolID + } + if mip.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = mip.MaintenanceConfigurationID + } + if mip.MinimalTLSVersion != nil { + objectMap["minimalTlsVersion"] = mip.MinimalTLSVersion + } + if mip.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = mip.RequestedBackupStorageRedundancy + } + if mip.ZoneRedundant != nil { + objectMap["zoneRedundant"] = mip.ZoneRedundant + } + if mip.PrimaryUserAssignedIdentityID != nil { + objectMap["primaryUserAssignedIdentityId"] = mip.PrimaryUserAssignedIdentityID + } + if mip.KeyID != nil { + objectMap["keyId"] = mip.KeyID + } + if mip.Administrators != nil { + objectMap["administrators"] = mip.Administrators + } + if mip.ServicePrincipal != nil { + objectMap["servicePrincipal"] = mip.ServicePrincipal + } + return json.Marshal(objectMap) +} + +// ManagedInstanceQuery database query. +type ManagedInstanceQuery struct { + autorest.Response `json:"-"` + // QueryProperties - Resource properties. + *QueryProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceQuery. +func (miq ManagedInstanceQuery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miq.QueryProperties != nil { + objectMap["properties"] = miq.QueryProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceQuery struct. +func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var queryProperties QueryProperties + err = json.Unmarshal(*v, &queryProperties) + if err != nil { + return err + } + miq.QueryProperties = &queryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miq.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miq.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miq.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceQueryStatistics execution statistics for one particular query +type ManagedInstanceQueryStatistics struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]QueryStatistics `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceQueryStatistics. +func (miqs ManagedInstanceQueryStatistics) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceQueryStatisticsIterator provides access to a complete listing of QueryStatistics values. +type ManagedInstanceQueryStatisticsIterator struct { + i int + page ManagedInstanceQueryStatisticsPage +} + +// NextWithContext 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 *ManagedInstanceQueryStatisticsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceQueryStatisticsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceQueryStatisticsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceQueryStatisticsIterator) 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 ManagedInstanceQueryStatisticsIterator) Response() ManagedInstanceQueryStatistics { + 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 ManagedInstanceQueryStatisticsIterator) Value() QueryStatistics { + if !iter.page.NotDone() { + return QueryStatistics{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceQueryStatisticsIterator type. +func NewManagedInstanceQueryStatisticsIterator(page ManagedInstanceQueryStatisticsPage) ManagedInstanceQueryStatisticsIterator { + return ManagedInstanceQueryStatisticsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miqs ManagedInstanceQueryStatistics) IsEmpty() bool { + return miqs.Value == nil || len(*miqs.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miqs ManagedInstanceQueryStatistics) hasNextLink() bool { + return miqs.NextLink != nil && len(*miqs.NextLink) != 0 +} + +// managedInstanceQueryStatisticsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miqs ManagedInstanceQueryStatistics) managedInstanceQueryStatisticsPreparer(ctx context.Context) (*http.Request, error) { + if !miqs.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miqs.NextLink))) +} + +// ManagedInstanceQueryStatisticsPage contains a page of QueryStatistics values. +type ManagedInstanceQueryStatisticsPage struct { + fn func(context.Context, ManagedInstanceQueryStatistics) (ManagedInstanceQueryStatistics, error) + miqs ManagedInstanceQueryStatistics +} + +// NextWithContext 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 *ManagedInstanceQueryStatisticsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceQueryStatisticsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miqs) + if err != nil { + return err + } + page.miqs = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceQueryStatisticsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceQueryStatisticsPage) NotDone() bool { + return !page.miqs.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceQueryStatisticsPage) Response() ManagedInstanceQueryStatistics { + return page.miqs +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceQueryStatisticsPage) Values() []QueryStatistics { + if page.miqs.IsEmpty() { + return nil + } + return *page.miqs.Value +} + +// Creates a new instance of the ManagedInstanceQueryStatisticsPage type. +func NewManagedInstanceQueryStatisticsPage(cur ManagedInstanceQueryStatistics, getNextPage func(context.Context, ManagedInstanceQueryStatistics) (ManagedInstanceQueryStatistics, error)) ManagedInstanceQueryStatisticsPage { + return ManagedInstanceQueryStatisticsPage{ + fn: getNextPage, + miqs: cur, + } +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesCreateOrUpdateFuture.Result. +func (future *ManagedInstancesCreateOrUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.CreateOrUpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil } -// MarshalJSON is the custom marshaler for ManagedInstanceProperties. -func (mip ManagedInstanceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mip.ManagedInstanceCreateMode != "" { - objectMap["managedInstanceCreateMode"] = mip.ManagedInstanceCreateMode - } - if mip.AdministratorLogin != nil { - objectMap["administratorLogin"] = mip.AdministratorLogin - } - if mip.AdministratorLoginPassword != nil { - objectMap["administratorLoginPassword"] = mip.AdministratorLoginPassword +// result is the default implementation for ManagedInstancesDeleteFuture.Result. +func (future *ManagedInstancesDeleteFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return } - if mip.SubnetID != nil { - objectMap["subnetId"] = mip.SubnetID + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + return } - if mip.LicenseType != "" { - objectMap["licenseType"] = mip.LicenseType + ar.Response = future.Response() + return +} + +// ManagedInstancesFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - if mip.VCores != nil { - objectMap["vCores"] = mip.VCores + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesFailoverFuture.Result. +func (future *ManagedInstancesFailoverFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesFailoverFuture", "Result", future.Response(), "Polling failure") + return } - if mip.StorageSizeInGB != nil { - objectMap["storageSizeInGB"] = mip.StorageSizeInGB + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesFailoverFuture") + return } - if mip.Collation != nil { - objectMap["collation"] = mip.Collation + ar.Response = future.Response() + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - if mip.DNSZonePartner != nil { - objectMap["dnsZonePartner"] = mip.DNSZonePartner + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesUpdateFuture.Result. +func (future *ManagedInstancesUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return } - if mip.PublicDataEndpointEnabled != nil { - objectMap["publicDataEndpointEnabled"] = mip.PublicDataEndpointEnabled + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + return } - if mip.SourceManagedInstanceID != nil { - objectMap["sourceManagedInstanceId"] = mip.SourceManagedInstanceID + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.UpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } } - if mip.RestorePointInTime != nil { - objectMap["restorePointInTime"] = mip.RestorePointInTime + return +} + +// ManagedInstanceTdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceTdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceTdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceTdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err } - if mip.ProxyOverride != "" { - objectMap["proxyOverride"] = mip.ProxyOverride + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceTdeCertificatesCreateFuture.Result. +func (future *ManagedInstanceTdeCertificatesCreateFuture) result(client ManagedInstanceTdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return } - if mip.TimezoneID != nil { - objectMap["timezoneId"] = mip.TimezoneID + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceTdeCertificatesCreateFuture") + return } - if mip.InstancePoolID != nil { - objectMap["instancePoolId"] = mip.InstancePoolID + ar.Response = future.Response() + return +} + +// ManagedInstanceUpdate an update request for an Azure SQL Database managed instance. +type ManagedInstanceUpdate struct { + // Sku - Managed instance sku + Sku *Sku `json:"sku,omitempty"` + // Identity - Managed instance identity + Identity *ResourceIdentity `json:"identity,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceUpdate. +func (miu ManagedInstanceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miu.Sku != nil { + objectMap["sku"] = miu.Sku } - if mip.MaintenanceConfigurationID != nil { - objectMap["maintenanceConfigurationId"] = mip.MaintenanceConfigurationID + if miu.Identity != nil { + objectMap["identity"] = miu.Identity } - if mip.MinimalTLSVersion != nil { - objectMap["minimalTlsVersion"] = mip.MinimalTLSVersion + if miu.ManagedInstanceProperties != nil { + objectMap["properties"] = miu.ManagedInstanceProperties } - if mip.StorageAccountType != "" { - objectMap["storageAccountType"] = mip.StorageAccountType + if miu.Tags != nil { + objectMap["tags"] = miu.Tags } - if mip.ZoneRedundant != nil { - objectMap["zoneRedundant"] = mip.ZoneRedundant + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceUpdate struct. +func (miu *ManagedInstanceUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err } - if mip.PrimaryUserAssignedIdentityID != nil { - objectMap["primaryUserAssignedIdentityId"] = mip.PrimaryUserAssignedIdentityID + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + miu.Sku = &sku + } + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + miu.Identity = &identity + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + miu.ManagedInstanceProperties = &managedInstanceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + miu.Tags = tags + } + } } - if mip.KeyID != nil { - objectMap["keyId"] = mip.KeyID + + return nil +} + +// ManagedInstanceVcoresCapability the managed instance virtual cores capability. +type ManagedInstanceVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // IncludedMaxSize - READ-ONLY; Included size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedStorageSizes - READ-ONLY; Storage size ranges. + SupportedStorageSizes *[]MaxSizeRangeCapability `json:"supportedStorageSizes,omitempty"` + // InstancePoolSupported - READ-ONLY; True if this service objective is supported for managed instances in an instance pool. + InstancePoolSupported *bool `json:"instancePoolSupported,omitempty"` + // StandaloneSupported - READ-ONLY; True if this service objective is supported for standalone managed instances. + StandaloneSupported *bool `json:"standaloneSupported,omitempty"` + // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations + SupportedMaintenanceConfigurations *[]ManagedInstanceMaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVcoresCapability. +func (mivc ManagedInstanceVcoresCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason } - if mip.Administrators != nil { - objectMap["administrators"] = mip.Administrators + return json.Marshal(objectMap) +} + +// ManagedInstanceVersionCapability the managed instance capability +type ManagedInstanceVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported managed instance editions. + SupportedEditions *[]ManagedInstanceEditionCapability `json:"supportedEditions,omitempty"` + // SupportedInstancePoolEditions - READ-ONLY; The list of supported instance pool editions. + SupportedInstancePoolEditions *[]InstancePoolEditionCapability `json:"supportedInstancePoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVersionCapability. +func (mivc ManagedInstanceVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason } return json.Marshal(objectMap) } -// ManagedInstanceQuery database query. -type ManagedInstanceQuery struct { +// ManagedInstanceVulnerabilityAssessment a managed instance vulnerability assessment. +type ManagedInstanceVulnerabilityAssessment struct { autorest.Response `json:"-"` - // QueryProperties - Resource properties. - *QueryProperties `json:"properties,omitempty"` + // ManagedInstanceVulnerabilityAssessmentProperties - Resource properties. + *ManagedInstanceVulnerabilityAssessmentProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -18425,17 +20951,17 @@ type ManagedInstanceQuery struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceQuery. -func (miq ManagedInstanceQuery) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessment. +func (miva ManagedInstanceVulnerabilityAssessment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if miq.QueryProperties != nil { - objectMap["properties"] = miq.QueryProperties + if miva.ManagedInstanceVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = miva.ManagedInstanceVulnerabilityAssessmentProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceQuery struct. -func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceVulnerabilityAssessment struct. +func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -18445,12 +20971,12 @@ func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var queryProperties QueryProperties - err = json.Unmarshal(*v, &queryProperties) + var managedInstanceVulnerabilityAssessmentProperties ManagedInstanceVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &managedInstanceVulnerabilityAssessmentProperties) if err != nil { return err } - miq.QueryProperties = &queryProperties + miva.ManagedInstanceVulnerabilityAssessmentProperties = &managedInstanceVulnerabilityAssessmentProperties } case "id": if v != nil { @@ -18459,7 +20985,7 @@ func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { if err != nil { return err } - miq.ID = &ID + miva.ID = &ID } case "name": if v != nil { @@ -18468,7 +20994,7 @@ func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { if err != nil { return err } - miq.Name = &name + miva.Name = &name } case "type": if v != nil { @@ -18477,7 +21003,7 @@ func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { if err != nil { return err } - miq.Type = &typeVar + miva.Type = &typeVar } } } @@ -18485,32 +21011,34 @@ func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { return nil } -// ManagedInstanceQueryStatistics execution statistics for one particular query -type ManagedInstanceQueryStatistics struct { +// ManagedInstanceVulnerabilityAssessmentListResult a list of the ManagedInstance's vulnerability +// assessments. +type ManagedInstanceVulnerabilityAssessmentListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]QueryStatistics `json:"value,omitempty"` + Value *[]ManagedInstanceVulnerabilityAssessment `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceQueryStatistics. -func (miqs ManagedInstanceQueryStatistics) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessmentListResult. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceQueryStatisticsIterator provides access to a complete listing of QueryStatistics values. -type ManagedInstanceQueryStatisticsIterator struct { +// ManagedInstanceVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// ManagedInstanceVulnerabilityAssessment values. +type ManagedInstanceVulnerabilityAssessmentListResultIterator struct { i int - page ManagedInstanceQueryStatisticsPage + page ManagedInstanceVulnerabilityAssessmentListResultPage } // NextWithContext 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 *ManagedInstanceQueryStatisticsIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceQueryStatisticsIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -18535,67 +21063,68 @@ func (iter *ManagedInstanceQueryStatisticsIterator) NextWithContext(ctx context. // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceQueryStatisticsIterator) Next() error { +func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceQueryStatisticsIterator) NotDone() bool { +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) 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 ManagedInstanceQueryStatisticsIterator) Response() ManagedInstanceQueryStatistics { +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) Response() ManagedInstanceVulnerabilityAssessmentListResult { 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 ManagedInstanceQueryStatisticsIterator) Value() QueryStatistics { +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) Value() ManagedInstanceVulnerabilityAssessment { if !iter.page.NotDone() { - return QueryStatistics{} + return ManagedInstanceVulnerabilityAssessment{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceQueryStatisticsIterator type. -func NewManagedInstanceQueryStatisticsIterator(page ManagedInstanceQueryStatisticsPage) ManagedInstanceQueryStatisticsIterator { - return ManagedInstanceQueryStatisticsIterator{page: page} +// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultIterator type. +func NewManagedInstanceVulnerabilityAssessmentListResultIterator(page ManagedInstanceVulnerabilityAssessmentListResultPage) ManagedInstanceVulnerabilityAssessmentListResultIterator { + return ManagedInstanceVulnerabilityAssessmentListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (miqs ManagedInstanceQueryStatistics) IsEmpty() bool { - return miqs.Value == nil || len(*miqs.Value) == 0 +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) IsEmpty() bool { + return mivalr.Value == nil || len(*mivalr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (miqs ManagedInstanceQueryStatistics) hasNextLink() bool { - return miqs.NextLink != nil && len(*miqs.NextLink) != 0 +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) hasNextLink() bool { + return mivalr.NextLink != nil && len(*mivalr.NextLink) != 0 } -// managedInstanceQueryStatisticsPreparer prepares a request to retrieve the next set of results. +// managedInstanceVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (miqs ManagedInstanceQueryStatistics) managedInstanceQueryStatisticsPreparer(ctx context.Context) (*http.Request, error) { - if !miqs.hasNextLink() { +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) managedInstanceVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mivalr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(miqs.NextLink))) + autorest.WithBaseURL(to.String(mivalr.NextLink))) } -// ManagedInstanceQueryStatisticsPage contains a page of QueryStatistics values. -type ManagedInstanceQueryStatisticsPage struct { - fn func(context.Context, ManagedInstanceQueryStatistics) (ManagedInstanceQueryStatistics, error) - miqs ManagedInstanceQueryStatistics +// ManagedInstanceVulnerabilityAssessmentListResultPage contains a page of +// ManagedInstanceVulnerabilityAssessment values. +type ManagedInstanceVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error) + mivalr ManagedInstanceVulnerabilityAssessmentListResult } // NextWithContext 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 *ManagedInstanceQueryStatisticsPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceQueryStatisticsPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -18605,179 +21134,75 @@ func (page *ManagedInstanceQueryStatisticsPage) NextWithContext(ctx context.Cont }() } for { - next, err := page.fn(ctx, page.miqs) + next, err := page.fn(ctx, page.mivalr) if err != nil { return err } - page.miqs = next + page.mivalr = next if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// 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. -// Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceQueryStatisticsPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceQueryStatisticsPage) NotDone() bool { - return !page.miqs.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ManagedInstanceQueryStatisticsPage) Response() ManagedInstanceQueryStatistics { - return page.miqs -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceQueryStatisticsPage) Values() []QueryStatistics { - if page.miqs.IsEmpty() { - return nil - } - return *page.miqs.Value -} - -// Creates a new instance of the ManagedInstanceQueryStatisticsPage type. -func NewManagedInstanceQueryStatisticsPage(cur ManagedInstanceQueryStatistics, getNextPage func(context.Context, ManagedInstanceQueryStatistics) (ManagedInstanceQueryStatistics, error)) ManagedInstanceQueryStatisticsPage { - return ManagedInstanceQueryStatisticsPage{ - fn: getNextPage, - miqs: cur, - } -} - -// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedInstancesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstancesClient) (ManagedInstance, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstancesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedInstancesCreateOrUpdateFuture.Result. -func (future *ManagedInstancesCreateOrUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mi.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { - mi, err = client.CreateOrUpdateResponder(mi.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") - } - } - return -} - -// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ManagedInstancesDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstancesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstancesDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedInstancesDeleteFuture.Result. -func (future *ManagedInstancesDeleteFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") - return + break + } } - ar.Response = future.Response() - return + return nil } -// ManagedInstancesFailoverFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedInstancesFailoverFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedInstancesClient) (autorest.Response, error) +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstancesFailoverFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.mivalr.IsEmpty() } -// result is the default implementation for ManagedInstancesFailoverFuture.Result. -func (future *ManagedInstancesFailoverFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancesFailoverFuture", "Result", future.Response(), "Polling failure") - return +// Response returns the raw server response from the last page request. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Response() ManagedInstanceVulnerabilityAssessmentListResult { + return page.mivalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Values() []ManagedInstanceVulnerabilityAssessment { + if page.mivalr.IsEmpty() { + return nil } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesFailoverFuture") - return + return *page.mivalr.Value +} + +// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultPage type. +func NewManagedInstanceVulnerabilityAssessmentListResultPage(cur ManagedInstanceVulnerabilityAssessmentListResult, getNextPage func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error)) ManagedInstanceVulnerabilityAssessmentListResultPage { + return ManagedInstanceVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + mivalr: cur, } - ar.Response = future.Response() - return } -// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ManagedInstancesUpdateFuture struct { +// ManagedInstanceVulnerabilityAssessmentProperties properties of a managed instance vulnerability +// assessment. +type ManagedInstanceVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or a firewall + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet or a firewall + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for +// monitoring and retrieving the results of a long-running operation. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstancesClient) (ManagedInstance, error) + Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstancesUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -18787,40 +21212,40 @@ func (future *ManagedInstancesUpdateFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for ManagedInstancesUpdateFuture.Result. -func (future *ManagedInstancesUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { +// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - mi.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { - mi, err = client.UpdateResponder(mi.Response.Response) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") } } return } -// ManagedInstanceTdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ManagedInstanceTdeCertificatesCreateFuture struct { +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture an abstraction for +// monitoring and retrieving the results of a long-running operation. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ManagedInstanceTdeCertificatesClient) (autorest.Response, error) + Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedInstanceTdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -18830,163 +21255,34 @@ func (future *ManagedInstanceTdeCertificatesCreateFuture) UnmarshalJSON(body []b return nil } -// result is the default implementation for ManagedInstanceTdeCertificatesCreateFuture.Result. -func (future *ManagedInstanceTdeCertificatesCreateFuture) result(client ManagedInstanceTdeCertificatesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceTdeCertificatesCreateFuture") - return - } - ar.Response = future.Response() - return -} - -// ManagedInstanceUpdate an update request for an Azure SQL Database managed instance. -type ManagedInstanceUpdate struct { - // Sku - Managed instance sku - Sku *Sku `json:"sku,omitempty"` - // Identity - Managed instance identity - Identity *ResourceIdentity `json:"identity,omitempty"` - // ManagedInstanceProperties - Resource properties. - *ManagedInstanceProperties `json:"properties,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceUpdate. -func (miu ManagedInstanceUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if miu.Sku != nil { - objectMap["sku"] = miu.Sku - } - if miu.Identity != nil { - objectMap["identity"] = miu.Identity - } - if miu.ManagedInstanceProperties != nil { - objectMap["properties"] = miu.ManagedInstanceProperties - } - if miu.Tags != nil { - objectMap["tags"] = miu.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceUpdate struct. -func (miu *ManagedInstanceUpdate) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - miu.Sku = &sku - } - case "identity": - if v != nil { - var identity ResourceIdentity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - miu.Identity = &identity - } - case "properties": - if v != nil { - var managedInstanceProperties ManagedInstanceProperties - err = json.Unmarshal(*v, &managedInstanceProperties) - if err != nil { - return err - } - miu.ManagedInstanceProperties = &managedInstanceProperties - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - miu.Tags = tags - } - } - } - - return nil -} - -// ManagedInstanceVcoresCapability the managed instance virtual cores capability. -type ManagedInstanceVcoresCapability struct { - // Name - READ-ONLY; The virtual cores identifier. - Name *string `json:"name,omitempty"` - // Value - READ-ONLY; The virtual cores value. - Value *int32 `json:"value,omitempty"` - // IncludedMaxSize - READ-ONLY; Included size. - IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` - // SupportedStorageSizes - READ-ONLY; Storage size ranges. - SupportedStorageSizes *[]MaxSizeRangeCapability `json:"supportedStorageSizes,omitempty"` - // InstancePoolSupported - READ-ONLY; True if this service objective is supported for managed instances in an instance pool. - InstancePoolSupported *bool `json:"instancePoolSupported,omitempty"` - // StandaloneSupported - READ-ONLY; True if this service objective is supported for standalone managed instances. - StandaloneSupported *bool `json:"standaloneSupported,omitempty"` - // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations - SupportedMaintenanceConfigurations *[]ManagedInstanceMaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceVcoresCapability. -func (mivc ManagedInstanceVcoresCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mivc.Reason != nil { - objectMap["reason"] = mivc.Reason - } - return json.Marshal(objectMap) -} - -// ManagedInstanceVersionCapability the managed instance capability -type ManagedInstanceVersionCapability struct { - // Name - READ-ONLY; The server version name. - Name *string `json:"name,omitempty"` - // SupportedEditions - READ-ONLY; The list of supported managed instance editions. - SupportedEditions *[]ManagedInstanceEditionCapability `json:"supportedEditions,omitempty"` - // SupportedInstancePoolEditions - READ-ONLY; The list of supported instance pool editions. - SupportedInstancePoolEditions *[]InstancePoolEditionCapability `json:"supportedInstancePoolEditions,omitempty"` - // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` - // Reason - The reason for the capability not being available. - Reason *string `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedInstanceVersionCapability. -func (mivc ManagedInstanceVersionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mivc.Reason != nil { - objectMap["reason"] = mivc.Reason +// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return } - return json.Marshal(objectMap) + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return } -// ManagedInstanceVulnerabilityAssessment a managed instance vulnerability assessment. -type ManagedInstanceVulnerabilityAssessment struct { +// ManagedServerDNSAlias a managed server DNS alias. +type ManagedServerDNSAlias struct { autorest.Response `json:"-"` - // ManagedInstanceVulnerabilityAssessmentProperties - Resource properties. - *ManagedInstanceVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ManagedServerDNSAliasProperties - Resource properties. + *ManagedServerDNSAliasProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -18995,17 +21291,17 @@ type ManagedInstanceVulnerabilityAssessment struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessment. -func (miva ManagedInstanceVulnerabilityAssessment) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedServerDNSAlias. +func (msda ManagedServerDNSAlias) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if miva.ManagedInstanceVulnerabilityAssessmentProperties != nil { - objectMap["properties"] = miva.ManagedInstanceVulnerabilityAssessmentProperties + if msda.ManagedServerDNSAliasProperties != nil { + objectMap["properties"] = msda.ManagedServerDNSAliasProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ManagedInstanceVulnerabilityAssessment struct. -func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ManagedServerDNSAlias struct. +func (msda *ManagedServerDNSAlias) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -19015,12 +21311,12 @@ func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) e switch k { case "properties": if v != nil { - var managedInstanceVulnerabilityAssessmentProperties ManagedInstanceVulnerabilityAssessmentProperties - err = json.Unmarshal(*v, &managedInstanceVulnerabilityAssessmentProperties) + var managedServerDNSAliasProperties ManagedServerDNSAliasProperties + err = json.Unmarshal(*v, &managedServerDNSAliasProperties) if err != nil { return err } - miva.ManagedInstanceVulnerabilityAssessmentProperties = &managedInstanceVulnerabilityAssessmentProperties + msda.ManagedServerDNSAliasProperties = &managedServerDNSAliasProperties } case "id": if v != nil { @@ -19029,7 +21325,7 @@ func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) e if err != nil { return err } - miva.ID = &ID + msda.ID = &ID } case "name": if v != nil { @@ -19038,7 +21334,7 @@ func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) e if err != nil { return err } - miva.Name = &name + msda.Name = &name } case "type": if v != nil { @@ -19047,7 +21343,7 @@ func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) e if err != nil { return err } - miva.Type = &typeVar + msda.Type = &typeVar } } } @@ -19055,34 +21351,168 @@ func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) e return nil } -// ManagedInstanceVulnerabilityAssessmentListResult a list of the ManagedInstance's vulnerability -// assessments. -type ManagedInstanceVulnerabilityAssessmentListResult struct { +// ManagedServerDNSAliasAcquisition a managed server DNS alias acquisition request. +type ManagedServerDNSAliasAcquisition struct { + // OldManagedServerDNSAliasResourceID - The resource ID of the managed server DNS alias that will be acquired to point to this managed server instead. + OldManagedServerDNSAliasResourceID *string `json:"oldManagedServerDnsAliasResourceId,omitempty"` +} + +// ManagedServerDNSAliasCreation a managed server dns alias creation request. +type ManagedServerDNSAliasCreation struct { + // CreateDNSRecord - Whether or not DNS record should be created for this alias. + CreateDNSRecord *bool `json:"createDnsRecord,omitempty"` +} + +// ManagedServerDNSAliasesAcquireFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedServerDNSAliasesAcquireFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedServerDNSAliasesClient) (ManagedServerDNSAlias, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedServerDNSAliasesAcquireFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedServerDNSAliasesAcquireFuture.Result. +func (future *ManagedServerDNSAliasesAcquireFuture) result(client ManagedServerDNSAliasesClient) (msda ManagedServerDNSAlias, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesAcquireFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + msda.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedServerDNSAliasesAcquireFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if msda.Response.Response, err = future.GetResult(sender); err == nil && msda.Response.Response.StatusCode != http.StatusNoContent { + msda, err = client.AcquireResponder(msda.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesAcquireFuture", "Result", msda.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedServerDNSAliasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ManagedServerDNSAliasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedServerDNSAliasesClient) (ManagedServerDNSAlias, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedServerDNSAliasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedServerDNSAliasesCreateOrUpdateFuture.Result. +func (future *ManagedServerDNSAliasesCreateOrUpdateFuture) result(client ManagedServerDNSAliasesClient) (msda ManagedServerDNSAlias, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + msda.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedServerDNSAliasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if msda.Response.Response, err = future.GetResult(sender); err == nil && msda.Response.Response.StatusCode != http.StatusNoContent { + msda, err = client.CreateOrUpdateResponder(msda.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesCreateOrUpdateFuture", "Result", msda.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedServerDNSAliasesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedServerDNSAliasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedServerDNSAliasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedServerDNSAliasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedServerDNSAliasesDeleteFuture.Result. +func (future *ManagedServerDNSAliasesDeleteFuture) result(client ManagedServerDNSAliasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerDNSAliasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedServerDNSAliasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedServerDNSAliasListResult a list of managed server DNS aliases. +type ManagedServerDNSAliasListResult struct { autorest.Response `json:"-"` // Value - READ-ONLY; Array of results. - Value *[]ManagedInstanceVulnerabilityAssessment `json:"value,omitempty"` + Value *[]ManagedServerDNSAlias `json:"value,omitempty"` // NextLink - READ-ONLY; Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessmentListResult. -func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedServerDNSAliasListResult. +func (msdalr ManagedServerDNSAliasListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) return json.Marshal(objectMap) } -// ManagedInstanceVulnerabilityAssessmentListResultIterator provides access to a complete listing of -// ManagedInstanceVulnerabilityAssessment values. -type ManagedInstanceVulnerabilityAssessmentListResultIterator struct { +// ManagedServerDNSAliasListResultIterator provides access to a complete listing of ManagedServerDNSAlias +// values. +type ManagedServerDNSAliasListResultIterator struct { i int - page ManagedInstanceVulnerabilityAssessmentListResultPage + page ManagedServerDNSAliasListResultPage } // NextWithContext 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 *ManagedInstanceVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { +func (iter *ManagedServerDNSAliasListResultIterator) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultIterator.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasListResultIterator.NextWithContext") defer func() { sc := -1 if iter.Response().Response.Response != nil { @@ -19107,68 +21537,67 @@ func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) NextWithCo // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. // Deprecated: Use NextWithContext() instead. -func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) Next() error { +func (iter *ManagedServerDNSAliasListResultIterator) Next() error { return iter.NextWithContext(context.Background()) } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) NotDone() bool { +func (iter ManagedServerDNSAliasListResultIterator) 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 ManagedInstanceVulnerabilityAssessmentListResultIterator) Response() ManagedInstanceVulnerabilityAssessmentListResult { +func (iter ManagedServerDNSAliasListResultIterator) Response() ManagedServerDNSAliasListResult { 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 ManagedInstanceVulnerabilityAssessmentListResultIterator) Value() ManagedInstanceVulnerabilityAssessment { +func (iter ManagedServerDNSAliasListResultIterator) Value() ManagedServerDNSAlias { if !iter.page.NotDone() { - return ManagedInstanceVulnerabilityAssessment{} + return ManagedServerDNSAlias{} } return iter.page.Values()[iter.i] } -// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultIterator type. -func NewManagedInstanceVulnerabilityAssessmentListResultIterator(page ManagedInstanceVulnerabilityAssessmentListResultPage) ManagedInstanceVulnerabilityAssessmentListResultIterator { - return ManagedInstanceVulnerabilityAssessmentListResultIterator{page: page} +// Creates a new instance of the ManagedServerDNSAliasListResultIterator type. +func NewManagedServerDNSAliasListResultIterator(page ManagedServerDNSAliasListResultPage) ManagedServerDNSAliasListResultIterator { + return ManagedServerDNSAliasListResultIterator{page: page} } // IsEmpty returns true if the ListResult contains no values. -func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) IsEmpty() bool { - return mivalr.Value == nil || len(*mivalr.Value) == 0 +func (msdalr ManagedServerDNSAliasListResult) IsEmpty() bool { + return msdalr.Value == nil || len(*msdalr.Value) == 0 } // hasNextLink returns true if the NextLink is not empty. -func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) hasNextLink() bool { - return mivalr.NextLink != nil && len(*mivalr.NextLink) != 0 +func (msdalr ManagedServerDNSAliasListResult) hasNextLink() bool { + return msdalr.NextLink != nil && len(*msdalr.NextLink) != 0 } -// managedInstanceVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// managedServerDNSAliasListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. -func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) managedInstanceVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mivalr.hasNextLink() { +func (msdalr ManagedServerDNSAliasListResult) managedServerDNSAliasListResultPreparer(ctx context.Context) (*http.Request, error) { + if !msdalr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(mivalr.NextLink))) + autorest.WithBaseURL(to.String(msdalr.NextLink))) } -// ManagedInstanceVulnerabilityAssessmentListResultPage contains a page of -// ManagedInstanceVulnerabilityAssessment values. -type ManagedInstanceVulnerabilityAssessmentListResultPage struct { - fn func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error) - mivalr ManagedInstanceVulnerabilityAssessmentListResult +// ManagedServerDNSAliasListResultPage contains a page of ManagedServerDNSAlias values. +type ManagedServerDNSAliasListResultPage struct { + fn func(context.Context, ManagedServerDNSAliasListResult) (ManagedServerDNSAliasListResult, error) + msdalr ManagedServerDNSAliasListResult } // NextWithContext 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 *ManagedInstanceVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { +func (page *ManagedServerDNSAliasListResultPage) NextWithContext(ctx context.Context) (err error) { if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultPage.NextWithContext") + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerDNSAliasListResultPage.NextWithContext") defer func() { sc := -1 if page.Response().Response.Response != nil { @@ -19178,11 +21607,11 @@ func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) NextWithContex }() } for { - next, err := page.fn(ctx, page.mivalr) + next, err := page.fn(ctx, page.msdalr) if err != nil { return err } - page.mivalr = next + page.msdalr = next if !next.hasNextLink() || !next.IsEmpty() { break } @@ -19193,133 +21622,48 @@ func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) NextWithContex // 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. // Deprecated: Use NextWithContext() instead. -func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) Next() error { +func (page *ManagedServerDNSAliasListResultPage) Next() error { return page.NextWithContext(context.Background()) } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ManagedInstanceVulnerabilityAssessmentListResultPage) NotDone() bool { - return !page.mivalr.IsEmpty() +func (page ManagedServerDNSAliasListResultPage) NotDone() bool { + return !page.msdalr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Response() ManagedInstanceVulnerabilityAssessmentListResult { - return page.mivalr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Values() []ManagedInstanceVulnerabilityAssessment { - if page.mivalr.IsEmpty() { - return nil - } - return *page.mivalr.Value -} - -// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultPage type. -func NewManagedInstanceVulnerabilityAssessmentListResultPage(cur ManagedInstanceVulnerabilityAssessmentListResult, getNextPage func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error)) ManagedInstanceVulnerabilityAssessmentListResultPage { - return ManagedInstanceVulnerabilityAssessmentListResultPage{ - fn: getNextPage, - mivalr: cur, - } -} - -// ManagedInstanceVulnerabilityAssessmentProperties properties of a managed instance vulnerability -// assessment. -type ManagedInstanceVulnerabilityAssessmentProperties struct { - // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). - StorageContainerPath *string `json:"storageContainerPath,omitempty"` - // StorageContainerSasKey - A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or a firewall - StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` - // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet or a firewall - StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` - // RecurringScans - The recurring scans settings - RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` -} - -// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for -// monitoring and retrieving the results of a long-running operation. -type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. -func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mbstrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { - mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") - } - } - return -} - -// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture an abstraction for -// monitoring and retrieving the results of a long-running operation. -type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +func (page ManagedServerDNSAliasListResultPage) Response() ManagedServerDNSAliasListResult { + return page.msdalr } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedServerDNSAliasListResultPage) Values() []ManagedServerDNSAlias { + if page.msdalr.IsEmpty() { + return nil } - future.FutureAPI = &azFuture - future.Result = future.result - return nil + return *page.msdalr.Value } -// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture.Result. -func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mbstrp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { - mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") - } +// Creates a new instance of the ManagedServerDNSAliasListResultPage type. +func NewManagedServerDNSAliasListResultPage(cur ManagedServerDNSAliasListResult, getNextPage func(context.Context, ManagedServerDNSAliasListResult) (ManagedServerDNSAliasListResult, error)) ManagedServerDNSAliasListResultPage { + return ManagedServerDNSAliasListResultPage{ + fn: getNextPage, + msdalr: cur, } - return +} + +// ManagedServerDNSAliasProperties properties of a managed server DNS alias. +type ManagedServerDNSAliasProperties struct { + // AzureDNSRecord - READ-ONLY; The fully qualified DNS record for managed server alias + AzureDNSRecord *string `json:"azureDnsRecord,omitempty"` + // PublicAzureDNSRecord - READ-ONLY; The fully qualified public DNS record for managed server alias + PublicAzureDNSRecord *string `json:"publicAzureDnsRecord,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedServerDNSAliasProperties. +func (msdap ManagedServerDNSAliasProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) } // ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the @@ -20261,259 +22605,6 @@ func NewOperationListResultPage(cur OperationListResult, getNextPage func(contex } } -// OperationsHealth operations health status in a location. -type OperationsHealth struct { - // OperationsHealthProperties - Resource properties. - *OperationsHealthProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationsHealth. -func (oh OperationsHealth) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if oh.OperationsHealthProperties != nil { - objectMap["properties"] = oh.OperationsHealthProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for OperationsHealth struct. -func (oh *OperationsHealth) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var operationsHealthProperties OperationsHealthProperties - err = json.Unmarshal(*v, &operationsHealthProperties) - if err != nil { - return err - } - oh.OperationsHealthProperties = &operationsHealthProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - oh.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - oh.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - oh.Type = &typeVar - } - } - } - - return nil -} - -// OperationsHealthListResult a list of service health statuses in a location. -type OperationsHealthListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Array of results. - Value *[]OperationsHealth `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to retrieve next page of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationsHealthListResult. -func (ohlr OperationsHealthListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationsHealthListResultIterator provides access to a complete listing of OperationsHealth values. -type OperationsHealthListResultIterator struct { - i int - page OperationsHealthListResultPage -} - -// NextWithContext 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 *OperationsHealthListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationsHealthListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationsHealthListResultIterator) 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 OperationsHealthListResultIterator) Response() OperationsHealthListResult { - 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 OperationsHealthListResultIterator) Value() OperationsHealth { - if !iter.page.NotDone() { - return OperationsHealth{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationsHealthListResultIterator type. -func NewOperationsHealthListResultIterator(page OperationsHealthListResultPage) OperationsHealthListResultIterator { - return OperationsHealthListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (ohlr OperationsHealthListResult) IsEmpty() bool { - return ohlr.Value == nil || len(*ohlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (ohlr OperationsHealthListResult) hasNextLink() bool { - return ohlr.NextLink != nil && len(*ohlr.NextLink) != 0 -} - -// operationsHealthListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (ohlr OperationsHealthListResult) operationsHealthListResultPreparer(ctx context.Context) (*http.Request, error) { - if !ohlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(ohlr.NextLink))) -} - -// OperationsHealthListResultPage contains a page of OperationsHealth values. -type OperationsHealthListResultPage struct { - fn func(context.Context, OperationsHealthListResult) (OperationsHealthListResult, error) - ohlr OperationsHealthListResult -} - -// NextWithContext 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 *OperationsHealthListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.ohlr) - if err != nil { - return err - } - page.ohlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// 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. -// Deprecated: Use NextWithContext() instead. -func (page *OperationsHealthListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationsHealthListResultPage) NotDone() bool { - return !page.ohlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationsHealthListResultPage) Response() OperationsHealthListResult { - return page.ohlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationsHealthListResultPage) Values() []OperationsHealth { - if page.ohlr.IsEmpty() { - return nil - } - return *page.ohlr.Value -} - -// Creates a new instance of the OperationsHealthListResultPage type. -func NewOperationsHealthListResultPage(cur OperationsHealthListResult, getNextPage func(context.Context, OperationsHealthListResult) (OperationsHealthListResult, error)) OperationsHealthListResultPage { - return OperationsHealthListResultPage{ - fn: getNextPage, - ohlr: cur, - } -} - -// OperationsHealthProperties properties of an operation health. -type OperationsHealthProperties struct { - // Name - READ-ONLY; Operation name for the service - Name *string `json:"name,omitempty"` - // Health - READ-ONLY; Operation health status of the service. - Health *string `json:"health,omitempty"` - // Description - READ-ONLY; Health status description. - Description *string `json:"description,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationsHealthProperties. -func (ohp OperationsHealthProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - // OutboundFirewallRule an Azure SQL DB Server Outbound Firewall Rule. type OutboundFirewallRule struct { autorest.Response `json:"-"` @@ -22646,48 +24737,11 @@ type ReplicationLinksFailoverAllowDataLossFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ReplicationLinksClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ReplicationLinksFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ReplicationLinksFailoverAllowDataLossFuture.Result. -func (future *ReplicationLinksFailoverAllowDataLossFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") - return - } - ar.Response = future.Response() - return -} - -// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type ReplicationLinksFailoverFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ReplicationLinksClient) (autorest.Response, error) + Result func(ReplicationLinksClient) (ReplicationLink, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ReplicationLinksFailoverFuture) UnmarshalJSON(body []byte) error { +func (future *ReplicationLinksFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -22697,34 +24751,40 @@ func (future *ReplicationLinksFailoverFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for ReplicationLinksFailoverFuture.Result. -func (future *ReplicationLinksFailoverFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { +// result is the default implementation for ReplicationLinksFailoverAllowDataLossFuture.Result. +func (future *ReplicationLinksFailoverAllowDataLossFuture) result(client ReplicationLinksClient) (rl ReplicationLink, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") return } if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") + rl.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") return } - ar.Response = future.Response() + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rl.Response.Response, err = future.GetResult(sender); err == nil && rl.Response.Response.StatusCode != http.StatusNoContent { + rl, err = client.FailoverAllowDataLossResponder(rl.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", rl.Response.Response, "Failure responding to request") + } + } return } -// ReplicationLinksUnlinkFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ReplicationLinksUnlinkFuture struct { +// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ReplicationLinksFailoverFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ReplicationLinksClient) (autorest.Response, error) + Result func(ReplicationLinksClient) (ReplicationLink, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ReplicationLinksUnlinkFuture) UnmarshalJSON(body []byte) error { +func (future *ReplicationLinksFailoverFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -22734,20 +24794,26 @@ func (future *ReplicationLinksUnlinkFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for ReplicationLinksUnlinkFuture.Result. -func (future *ReplicationLinksUnlinkFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { +// result is the default implementation for ReplicationLinksFailoverFuture.Result. +func (future *ReplicationLinksFailoverFuture) result(client ReplicationLinksClient) (rl ReplicationLink, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ReplicationLinksUnlinkFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") return } if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksUnlinkFuture") + rl.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") return } - ar.Response = future.Response() + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rl.Response.Response, err = future.GetResult(sender); err == nil && rl.Response.Response.StatusCode != http.StatusNoContent { + rl, err = client.FailoverResponder(rl.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", rl.Response.Response, "Failure responding to request") + } + } return } @@ -22773,7 +24839,7 @@ type ResourceIdentity struct { UserAssignedIdentities map[string]*UserIdentity `json:"userAssignedIdentities"` // PrincipalID - READ-ONLY; The Azure Active Directory principal id. PrincipalID *uuid.UUID `json:"principalId,omitempty"` - // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'IdentityTypeNone', 'IdentityTypeSystemAssigned', 'IdentityTypeUserAssigned' + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'IdentityTypeNone', 'IdentityTypeSystemAssigned', 'IdentityTypeUserAssigned', 'IdentityTypeSystemAssignedUserAssigned' Type IdentityType `json:"type,omitempty"` // TenantID - READ-ONLY; The Azure Active Directory tenant id. TenantID *uuid.UUID `json:"tenantId,omitempty"` @@ -22791,30 +24857,6 @@ func (ri ResourceIdentity) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// ResourceIdentityWithUserAssignedIdentities azure Active Directory identity configuration for a resource. -type ResourceIdentityWithUserAssignedIdentities struct { - // UserAssignedIdentities - The resource ids of the user assigned identities to use - UserAssignedIdentities map[string]*UserIdentity `json:"userAssignedIdentities"` - // PrincipalID - READ-ONLY; The Azure Active Directory principal id. - PrincipalID *uuid.UUID `json:"principalId,omitempty"` - // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'IdentityTypeNone', 'IdentityTypeSystemAssigned', 'IdentityTypeUserAssigned' - Type IdentityType `json:"type,omitempty"` - // TenantID - READ-ONLY; The Azure Active Directory tenant id. - TenantID *uuid.UUID `json:"tenantId,omitempty"` -} - -// MarshalJSON is the custom marshaler for ResourceIdentityWithUserAssignedIdentities. -func (riwuai ResourceIdentityWithUserAssignedIdentities) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if riwuai.UserAssignedIdentities != nil { - objectMap["userAssignedIdentities"] = riwuai.UserAssignedIdentities - } - if riwuai.Type != "" { - objectMap["type"] = riwuai.Type - } - return json.Marshal(objectMap) -} - // ResourceMoveDefinition contains the information necessary to perform a resource move (rename). type ResourceMoveDefinition struct { // ID - The target ID for the resource @@ -23127,16 +25169,14 @@ type RestorableDroppedDatabaseProperties struct { DatabaseName *string `json:"databaseName,omitempty"` // MaxSizeBytes - READ-ONLY; The max size of the database expressed in bytes. MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` - // ElasticPoolID - READ-ONLY; DEPRECATED: The resource name of the elastic pool containing this database. This property is deprecated and the value will always be null. - ElasticPoolID *string `json:"elasticPoolId,omitempty"` // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). CreationDate *date.Time `json:"creationDate,omitempty"` // DeletionDate - READ-ONLY; The deletion date of the database (ISO8601 format). DeletionDate *date.Time `json:"deletionDate,omitempty"` // EarliestRestoreDate - READ-ONLY; The earliest restore date of the database (ISO8601 format). EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` - // BackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'BackupStorageRedundancy1Geo', 'BackupStorageRedundancy1Local', 'BackupStorageRedundancy1Zone' - BackupStorageRedundancy BackupStorageRedundancy1 `json:"backupStorageRedundancy,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` } // MarshalJSON is the custom marshaler for RestorableDroppedDatabaseProperties. @@ -24642,6 +26682,133 @@ func (s *Server) UnmarshalJSON(body []byte) error { return nil } +// ServerAdvancedThreatProtection a server Advanced Threat Protection. +type ServerAdvancedThreatProtection struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of AdvancedThreatProtectionResource. + SystemData *SystemData `json:"systemData,omitempty"` + // AdvancedThreatProtectionProperties - Resource properties. + *AdvancedThreatProtectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAdvancedThreatProtection. +func (satp ServerAdvancedThreatProtection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if satp.AdvancedThreatProtectionProperties != nil { + objectMap["properties"] = satp.AdvancedThreatProtectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAdvancedThreatProtection struct. +func (satp *ServerAdvancedThreatProtection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + satp.SystemData = &systemData + } + case "properties": + if v != nil { + var advancedThreatProtectionProperties AdvancedThreatProtectionProperties + err = json.Unmarshal(*v, &advancedThreatProtectionProperties) + if err != nil { + return err + } + satp.AdvancedThreatProtectionProperties = &advancedThreatProtectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + satp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + satp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + satp.Type = &typeVar + } + } + } + + return nil +} + +// ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAdvancedThreatProtectionSettingsClient) (ServerAdvancedThreatProtection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture.Result. +func (future *ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture) result(client ServerAdvancedThreatProtectionSettingsClient) (satp ServerAdvancedThreatProtection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + satp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if satp.Response.Response, err = future.GetResult(sender); err == nil && satp.Response.Response.StatusCode != http.StatusNoContent { + satp, err = client.CreateOrUpdateResponder(satp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture", "Result", satp.Response.Response, "Failure responding to request") + } + } + return +} + // ServerAutomaticTuning server-level Automatic Tuning. type ServerAutomaticTuning struct { autorest.Response `json:"-"` @@ -25350,6 +27517,10 @@ type ServerBlobAuditingPolicyProperties struct { // USER_CHANGE_PASSWORD_GROUP // BATCH_STARTED_GROUP // BATCH_COMPLETED_GROUP + // DBCC_GROUP + // DATABASE_OWNERSHIP_CHANGE_GROUP + // DATABASE_CHANGE_GROUP + // LEDGER_OPERATION_GROUP // // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. // @@ -25393,6 +27564,8 @@ type ServerBlobAuditingPolicyProperties struct { // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // IsManagedIdentityInUse - Specifies whether Managed Identity is used to access blob storage + IsManagedIdentityInUse *bool `json:"isManagedIdentityInUse,omitempty"` // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' State BlobAuditingPolicyState `json:"state,omitempty"` // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. @@ -25570,14 +27743,57 @@ func (future *ServerCommunicationLinksCreateOrUpdateFuture) result(client Server return } -// ServerConnectionPolicy a server secure connection policy. +// ServerConnectionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerConnectionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerConnectionPoliciesClient) (ServerConnectionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerConnectionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerConnectionPoliciesCreateOrUpdateFuture.Result. +func (future *ServerConnectionPoliciesCreateOrUpdateFuture) result(client ServerConnectionPoliciesClient) (scp ServerConnectionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + scp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerConnectionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if scp.Response.Response, err = future.GetResult(sender); err == nil && scp.Response.Response.StatusCode != http.StatusNoContent { + scp, err = client.CreateOrUpdateResponder(scp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesCreateOrUpdateFuture", "Result", scp.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerConnectionPolicy a server connection policy type ServerConnectionPolicy struct { autorest.Response `json:"-"` - // Kind - READ-ONLY; Metadata used for the Azure portal experience. - Kind *string `json:"kind,omitempty"` // Location - READ-ONLY; Resource location. Location *string `json:"location,omitempty"` - // ServerConnectionPolicyProperties - The properties of the server secure connection policy. + // Kind - READ-ONLY; Metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ServerConnectionPolicyProperties - Resource properties. *ServerConnectionPolicyProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` @@ -25605,23 +27821,23 @@ func (scp *ServerConnectionPolicy) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "kind": + case "location": if v != nil { - var kind string - err = json.Unmarshal(*v, &kind) + var location string + err = json.Unmarshal(*v, &location) if err != nil { return err } - scp.Kind = &kind + scp.Location = &location } - case "location": + case "kind": if v != nil { - var location string - err = json.Unmarshal(*v, &location) + var kind string + err = json.Unmarshal(*v, &kind) if err != nil { return err } - scp.Location = &location + scp.Kind = &kind } case "properties": if v != nil { @@ -25661,13 +27877,179 @@ func (scp *ServerConnectionPolicy) UnmarshalJSON(body []byte) error { } } } - + + return nil +} + +// ServerConnectionPolicyListResult a list of server connection policy objects. +type ServerConnectionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerConnectionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerConnectionPolicyListResult. +func (scplr ServerConnectionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerConnectionPolicyListResultIterator provides access to a complete listing of ServerConnectionPolicy +// values. +type ServerConnectionPolicyListResultIterator struct { + i int + page ServerConnectionPolicyListResultPage +} + +// NextWithContext 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 *ServerConnectionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerConnectionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerConnectionPolicyListResultIterator) 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 ServerConnectionPolicyListResultIterator) Response() ServerConnectionPolicyListResult { + 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 ServerConnectionPolicyListResultIterator) Value() ServerConnectionPolicy { + if !iter.page.NotDone() { + return ServerConnectionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerConnectionPolicyListResultIterator type. +func NewServerConnectionPolicyListResultIterator(page ServerConnectionPolicyListResultPage) ServerConnectionPolicyListResultIterator { + return ServerConnectionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (scplr ServerConnectionPolicyListResult) IsEmpty() bool { + return scplr.Value == nil || len(*scplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (scplr ServerConnectionPolicyListResult) hasNextLink() bool { + return scplr.NextLink != nil && len(*scplr.NextLink) != 0 +} + +// serverConnectionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (scplr ServerConnectionPolicyListResult) serverConnectionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !scplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(scplr.NextLink))) +} + +// ServerConnectionPolicyListResultPage contains a page of ServerConnectionPolicy values. +type ServerConnectionPolicyListResultPage struct { + fn func(context.Context, ServerConnectionPolicyListResult) (ServerConnectionPolicyListResult, error) + scplr ServerConnectionPolicyListResult +} + +// NextWithContext 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 *ServerConnectionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.scplr) + if err != nil { + return err + } + page.scplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } return nil } -// ServerConnectionPolicyProperties the properties of a server secure connection policy. +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerConnectionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerConnectionPolicyListResultPage) NotDone() bool { + return !page.scplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerConnectionPolicyListResultPage) Response() ServerConnectionPolicyListResult { + return page.scplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerConnectionPolicyListResultPage) Values() []ServerConnectionPolicy { + if page.scplr.IsEmpty() { + return nil + } + return *page.scplr.Value +} + +// Creates a new instance of the ServerConnectionPolicyListResultPage type. +func NewServerConnectionPolicyListResultPage(cur ServerConnectionPolicyListResult, getNextPage func(context.Context, ServerConnectionPolicyListResult) (ServerConnectionPolicyListResult, error)) ServerConnectionPolicyListResultPage { + return ServerConnectionPolicyListResultPage{ + fn: getNextPage, + scplr: cur, + } +} + +// ServerConnectionPolicyProperties the properties of a server connection policy. type ServerConnectionPolicyProperties struct { - // ConnectionType - The server connection type. Possible values include: 'ServerConnectionTypeDefault', 'ServerConnectionTypeProxy', 'ServerConnectionTypeRedirect' + // ConnectionType - The server connection type. Possible values include: 'ServerConnectionTypeDefault', 'ServerConnectionTypeRedirect', 'ServerConnectionTypeProxy' ConnectionType ServerConnectionType `json:"connectionType,omitempty"` } @@ -27286,20 +29668,227 @@ func (sp ServerProperties) MarshalJSON() ([]byte, error) { if sp.RestrictOutboundNetworkAccess != "" { objectMap["restrictOutboundNetworkAccess"] = sp.RestrictOutboundNetworkAccess } - return json.Marshal(objectMap) + return json.Marshal(objectMap) +} + +// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersCreateOrUpdateFuture.Result. +func (future *ServersCreateOrUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateOrUpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerSecurityAlertPoliciesClient) (ServerSecurityAlertPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerSecurityAlertPoliciesCreateOrUpdateFuture.Result. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) result(client ServerSecurityAlertPoliciesClient) (ssap ServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ssap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ssap.Response.Response, err = future.GetResult(sender); err == nil && ssap.Response.Response.StatusCode != http.StatusNoContent { + ssap, err = client.CreateOrUpdateResponder(ssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", ssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerSecurityAlertPolicy a server security alert policy. +type ServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of SecurityAlertPolicyResource. + SystemData *SystemData `json:"systemData,omitempty"` + // SecurityAlertsPolicyProperties - Resource properties. + *SecurityAlertsPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicy. +func (ssap ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ssap.SecurityAlertsPolicyProperties != nil { + objectMap["properties"] = ssap.SecurityAlertsPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerSecurityAlertPolicy struct. +func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + ssap.SystemData = &systemData + } + case "properties": + if v != nil { + var securityAlertsPolicyProperties SecurityAlertsPolicyProperties + err = json.Unmarshal(*v, &securityAlertsPolicyProperties) + if err != nil { + return err + } + ssap.SecurityAlertsPolicyProperties = &securityAlertsPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ssap.Type = &typeVar + } + } + } + + return nil } -// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// ServersImportDatabaseFuture an abstraction for monitoring and retrieving the results of a long-running // operation. -type ServersCreateOrUpdateFuture struct { +type ServersImportDatabaseFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ServersClient) (Server, error) + Result func(ServersClient) (ImportExportOperationResult, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ServersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ServersImportDatabaseFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -27309,77 +29898,40 @@ func (future *ServersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { return nil } -// result is the default implementation for ServersCreateOrUpdateFuture.Result. -func (future *ServersCreateOrUpdateFuture) result(client ServersClient) (s Server, err error) { +// result is the default implementation for ServersImportDatabaseFuture.Result. +func (future *ServersImportDatabaseFuture) result(client ServersClient) (ieor ImportExportOperationResult, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", future.Response(), "Polling failure") return } if !done { - s.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersImportDatabaseFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { - s, err = client.CreateOrUpdateResponder(s.Response.Response) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ImportDatabaseResponder(ieor.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", ieor.Response.Response, "Failure responding to request") } } return } -// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. -type ServersDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ServersClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for ServersDeleteFuture.Result. -func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// ServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type ServerSecurityAlertPoliciesCreateOrUpdateFuture struct { +type ServersUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ServerSecurityAlertPoliciesClient) (ServerSecurityAlertPolicy, error) + Result func(ServersClient) (Server, error) } // UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { +func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error { var azFuture azure.Future if err := json.Unmarshal(body, &azFuture); err != nil { return err @@ -27389,36 +29941,35 @@ func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(bod return nil } -// result is the default implementation for ServerSecurityAlertPoliciesCreateOrUpdateFuture.Result. -func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) result(client ServerSecurityAlertPoliciesClient) (ssap ServerSecurityAlertPolicy, err error) { +// result is the default implementation for ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { var done bool done, err = future.DoneWithContext(context.Background(), client) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") return } if !done { - ssap.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture") + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") return } sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ssap.Response.Response, err = future.GetResult(sender); err == nil && ssap.Response.Response.StatusCode != http.StatusNoContent { - ssap, err = client.CreateOrUpdateResponder(ssap.Response.Response) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", ssap.Response.Response, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") } } return } -// ServerSecurityAlertPolicy a server security alert policy. -type ServerSecurityAlertPolicy struct { +// ServerTrustCertificate server trust certificate imported from box to enable connection between box and +// Sql Managed Instance. +type ServerTrustCertificate struct { autorest.Response `json:"-"` - // SystemData - READ-ONLY; SystemData of SecurityAlertPolicyResource. - SystemData *SystemData `json:"systemData,omitempty"` - // SecurityAlertsPolicyProperties - Resource properties. - *SecurityAlertsPolicyProperties `json:"properties,omitempty"` + // ServerTrustCertificateProperties - Resource properties. + *ServerTrustCertificateProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource ID. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -27427,17 +29978,17 @@ type ServerSecurityAlertPolicy struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicy. -func (ssap ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ServerTrustCertificate. +func (stc ServerTrustCertificate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ssap.SecurityAlertsPolicyProperties != nil { - objectMap["properties"] = ssap.SecurityAlertsPolicyProperties + if stc.ServerTrustCertificateProperties != nil { + objectMap["properties"] = stc.ServerTrustCertificateProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for ServerSecurityAlertPolicy struct. -func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { +// UnmarshalJSON is the custom unmarshaler for ServerTrustCertificate struct. +func (stc *ServerTrustCertificate) UnmarshalJSON(body []byte) error { var m map[string]*json.RawMessage err := json.Unmarshal(body, &m) if err != nil { @@ -27445,23 +29996,14 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - ssap.SystemData = &systemData - } case "properties": if v != nil { - var securityAlertsPolicyProperties SecurityAlertsPolicyProperties - err = json.Unmarshal(*v, &securityAlertsPolicyProperties) + var serverTrustCertificateProperties ServerTrustCertificateProperties + err = json.Unmarshal(*v, &serverTrustCertificateProperties) if err != nil { return err } - ssap.SecurityAlertsPolicyProperties = &securityAlertsPolicyProperties + stc.ServerTrustCertificateProperties = &serverTrustCertificateProperties } case "id": if v != nil { @@ -27470,7 +30012,7 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - ssap.ID = &ID + stc.ID = &ID } case "name": if v != nil { @@ -27479,7 +30021,7 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - ssap.Name = &name + stc.Name = &name } case "type": if v != nil { @@ -27488,7 +30030,7 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { if err != nil { return err } - ssap.Type = &typeVar + stc.Type = &typeVar } } } @@ -27496,90 +30038,269 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { return nil } -// ServersImportDatabaseFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ServersImportDatabaseFuture struct { +// ServerTrustCertificateProperties the properties of a server trust certificate. +type ServerTrustCertificateProperties struct { + // PublicBlob - The certificate public blob + PublicBlob *string `json:"publicBlob,omitempty"` + // Thumbprint - READ-ONLY; The certificate thumbprint + Thumbprint *string `json:"thumbprint,omitempty"` + // CertificateName - READ-ONLY; The certificate name + CertificateName *string `json:"certificateName,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerTrustCertificateProperties. +func (stcp ServerTrustCertificateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stcp.PublicBlob != nil { + objectMap["publicBlob"] = stcp.PublicBlob + } + return json.Marshal(objectMap) +} + +// ServerTrustCertificatesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerTrustCertificatesCreateOrUpdateFuture struct { azure.FutureAPI // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. - Result func(ServersClient) (ImportExportOperationResult, error) + Result func(ServerTrustCertificatesClient) (ServerTrustCertificate, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerTrustCertificatesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerTrustCertificatesCreateOrUpdateFuture.Result. +func (future *ServerTrustCertificatesCreateOrUpdateFuture) result(client ServerTrustCertificatesClient) (stc ServerTrustCertificate, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + stc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerTrustCertificatesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if stc.Response.Response, err = future.GetResult(sender); err == nil && stc.Response.Response.StatusCode != http.StatusNoContent { + stc, err = client.CreateOrUpdateResponder(stc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesCreateOrUpdateFuture", "Result", stc.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerTrustCertificatesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerTrustCertificatesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerTrustCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerTrustCertificatesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerTrustCertificatesDeleteFuture.Result. +func (future *ServerTrustCertificatesDeleteFuture) result(client ServerTrustCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerTrustCertificatesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerTrustCertificatesListResult a list of server trust certificates in instance. +type ServerTrustCertificatesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerTrustCertificate `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerTrustCertificatesListResult. +func (stclr ServerTrustCertificatesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerTrustCertificatesListResultIterator provides access to a complete listing of +// ServerTrustCertificate values. +type ServerTrustCertificatesListResultIterator struct { + i int + page ServerTrustCertificatesListResultPage +} + +// NextWithContext 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 *ServerTrustCertificatesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerTrustCertificatesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerTrustCertificatesListResultIterator) 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 ServerTrustCertificatesListResultIterator) Response() ServerTrustCertificatesListResult { + 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 ServerTrustCertificatesListResultIterator) Value() ServerTrustCertificate { + if !iter.page.NotDone() { + return ServerTrustCertificate{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerTrustCertificatesListResultIterator type. +func NewServerTrustCertificatesListResultIterator(page ServerTrustCertificatesListResultPage) ServerTrustCertificatesListResultIterator { + return ServerTrustCertificatesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (stclr ServerTrustCertificatesListResult) IsEmpty() bool { + return stclr.Value == nil || len(*stclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (stclr ServerTrustCertificatesListResult) hasNextLink() bool { + return stclr.NextLink != nil && len(*stclr.NextLink) != 0 } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ServersImportDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err +// serverTrustCertificatesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (stclr ServerTrustCertificatesListResult) serverTrustCertificatesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !stclr.hasNextLink() { + return nil, nil } - future.FutureAPI = &azFuture - future.Result = future.result - return nil + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(stclr.NextLink))) } -// result is the default implementation for ServersImportDatabaseFuture.Result. -func (future *ServersImportDatabaseFuture) result(client ServersClient) (ieor ImportExportOperationResult, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ieor.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ServersImportDatabaseFuture") - return +// ServerTrustCertificatesListResultPage contains a page of ServerTrustCertificate values. +type ServerTrustCertificatesListResultPage struct { + fn func(context.Context, ServerTrustCertificatesListResult) (ServerTrustCertificatesListResult, error) + stclr ServerTrustCertificatesListResult +} + +// NextWithContext 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 *ServerTrustCertificatesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { - ieor, err = client.ImportDatabaseResponder(ieor.Response.Response) + for { + next, err := page.fn(ctx, page.stclr) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", ieor.Response.Response, "Failure responding to request") + return err + } + page.stclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break } } - return + return nil } -// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ServersUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(ServersClient) (Server, error) +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServerTrustCertificatesListResultPage) Next() error { + return page.NextWithContext(context.Background()) } -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerTrustCertificatesListResultPage) NotDone() bool { + return !page.stclr.IsEmpty() } -// result is the default implementation for ServersUpdateFuture.Result. -func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - s.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") - return +// Response returns the raw server response from the last page request. +func (page ServerTrustCertificatesListResultPage) Response() ServerTrustCertificatesListResult { + return page.stclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerTrustCertificatesListResultPage) Values() []ServerTrustCertificate { + if page.stclr.IsEmpty() { + return nil } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { - s, err = client.UpdateResponder(s.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") - } + return *page.stclr.Value +} + +// Creates a new instance of the ServerTrustCertificatesListResultPage type. +func NewServerTrustCertificatesListResultPage(cur ServerTrustCertificatesListResult, getNextPage func(context.Context, ServerTrustCertificatesListResult) (ServerTrustCertificatesListResult, error)) ServerTrustCertificatesListResultPage { + return ServerTrustCertificatesListResultPage{ + fn: getNextPage, + stclr: cur, } - return } // ServerTrustGroup a server trust group. @@ -28421,6 +31142,27 @@ func (sop ServiceObjectiveProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// ServicePrincipal the managed instance's service principal configuration for a resource. +type ServicePrincipal struct { + // PrincipalID - READ-ONLY; The Azure Active Directory application object id. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The Azure Active Directory application client id. + ClientID *string `json:"clientId,omitempty"` + // TenantID - READ-ONLY; The Azure Active Directory tenant id. + TenantID *string `json:"tenantId,omitempty"` + // Type - Service principal type. Possible values include: 'ServicePrincipalTypeNone', 'ServicePrincipalTypeSystemAssigned' + Type ServicePrincipalType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrincipal. +func (sp ServicePrincipal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.Type != "" { + objectMap["type"] = sp.Type + } + return json.Marshal(objectMap) +} + // Sku an ARM Resource SKU. type Sku struct { // Name - The name of the SKU, typically, a letter + Number code, e.g. P3. @@ -28453,8 +31195,8 @@ func (sum SloUsageMetric) MarshalJSON() ([]byte, error) { // StorageCapability the storage account type capability. type StorageCapability struct { - // StorageAccountType - READ-ONLY; The storage account type for the database's backups. Possible values include: 'StorageAccountType1GRS', 'StorageAccountType1LRS', 'StorageAccountType1ZRS' - StorageAccountType StorageAccountType1 `json:"storageAccountType,omitempty"` + // StorageAccountType - READ-ONLY; The storage account type for the database's backups. Possible values include: 'StorageAccountTypeGRS', 'StorageAccountTypeLRS', 'StorageAccountTypeZRS' + StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' Status CapabilityStatus `json:"status,omitempty"` // Reason - The reason for the capability not being available. @@ -31497,206 +34239,10 @@ func (tr TrackedResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// TransparentDataEncryption represents a database transparent data encryption configuration. -type TransparentDataEncryption struct { - autorest.Response `json:"-"` - // Location - READ-ONLY; Resource location. - Location *string `json:"location,omitempty"` - // TransparentDataEncryptionProperties - Represents the properties of the resource. - *TransparentDataEncryptionProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for TransparentDataEncryption. -func (tde TransparentDataEncryption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tde.TransparentDataEncryptionProperties != nil { - objectMap["properties"] = tde.TransparentDataEncryptionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryption struct. -func (tde *TransparentDataEncryption) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - tde.Location = &location - } - case "properties": - if v != nil { - var transparentDataEncryptionProperties TransparentDataEncryptionProperties - err = json.Unmarshal(*v, &transparentDataEncryptionProperties) - if err != nil { - return err - } - tde.TransparentDataEncryptionProperties = &transparentDataEncryptionProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - tde.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - tde.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - tde.Type = &typeVar - } - } - } - - return nil -} - -// TransparentDataEncryptionActivity represents a database transparent data encryption Scan. -type TransparentDataEncryptionActivity struct { - // Location - READ-ONLY; Resource location. - Location *string `json:"location,omitempty"` - // TransparentDataEncryptionActivityProperties - Represents the properties of the resource. - *TransparentDataEncryptionActivityProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivity. -func (tdea TransparentDataEncryptionActivity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tdea.TransparentDataEncryptionActivityProperties != nil { - objectMap["properties"] = tdea.TransparentDataEncryptionActivityProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryptionActivity struct. -func (tdea *TransparentDataEncryptionActivity) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - tdea.Location = &location - } - case "properties": - if v != nil { - var transparentDataEncryptionActivityProperties TransparentDataEncryptionActivityProperties - err = json.Unmarshal(*v, &transparentDataEncryptionActivityProperties) - if err != nil { - return err - } - tdea.TransparentDataEncryptionActivityProperties = &transparentDataEncryptionActivityProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - tdea.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - tdea.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - tdea.Type = &typeVar - } - } - } - - return nil -} - -// TransparentDataEncryptionActivityListResult represents the response to a list database transparent data -// encryption activity request. -type TransparentDataEncryptionActivityListResult struct { - autorest.Response `json:"-"` - // Value - The list of database transparent data encryption activities. - Value *[]TransparentDataEncryptionActivity `json:"value,omitempty"` -} - -// TransparentDataEncryptionActivityProperties represents the properties of a database transparent data -// encryption Scan. -type TransparentDataEncryptionActivityProperties struct { - // Status - READ-ONLY; The status of the database. Possible values include: 'TransparentDataEncryptionActivityStatusEncrypting', 'TransparentDataEncryptionActivityStatusDecrypting' - Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` - // PercentComplete - READ-ONLY; The percent complete of the transparent data encryption scan for a database. - PercentComplete *float64 `json:"percentComplete,omitempty"` -} - -// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivityProperties. -func (tdeap TransparentDataEncryptionActivityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// TransparentDataEncryptionProperties represents the properties of a database transparent data encryption. +// TransparentDataEncryptionProperties properties of a transparent data encryption. type TransparentDataEncryptionProperties struct { - // Status - The status of the database transparent data encryption. Possible values include: 'TransparentDataEncryptionStatusEnabled', 'TransparentDataEncryptionStatusDisabled' - Status TransparentDataEncryptionStatus `json:"status,omitempty"` -} - -// UnlinkParameters represents the parameters for Unlink Replication Link request. -type UnlinkParameters struct { - // ForcedTermination - Determines whether link will be terminated in a forced or a friendly way. - ForcedTermination *bool `json:"forcedTermination,omitempty"` + // State - Specifies the state of the transparent data encryption. Possible values include: 'TransparentDataEncryptionStateEnabled', 'TransparentDataEncryptionStateDisabled' + State TransparentDataEncryptionState `json:"state,omitempty"` } // UpdateLongTermRetentionBackupParameters contains the information necessary to perform long term @@ -31742,8 +34288,8 @@ func (ultrbp *UpdateLongTermRetentionBackupParameters) UnmarshalJSON(body []byte // UpdateLongTermRetentionBackupParametersProperties contains the properties to perform long term retention // backup copy operation. type UpdateLongTermRetentionBackupParametersProperties struct { - // RequestedBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'RequestedBackupStorageRedundancyGeo', 'RequestedBackupStorageRedundancyLocal', 'RequestedBackupStorageRedundancyZone' - RequestedBackupStorageRedundancy RequestedBackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone', 'BackupStorageRedundancyGeoZone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` } // UpdateManagedInstanceDNSServersOperation a recoverable managed database resource. diff --git a/services/preview/sql/mgmt/v5.0/sql/operationshealth.go b/services/preview/sql/mgmt/v5.0/sql/operationshealth.go deleted file mode 100644 index 336375cc7e29..000000000000 --- a/services/preview/sql/mgmt/v5.0/sql/operationshealth.go +++ /dev/null @@ -1,150 +0,0 @@ -package sql - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// 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/tracing" - "net/http" -) - -// OperationsHealthClient 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 OperationsHealthClient struct { - BaseClient -} - -// NewOperationsHealthClient creates an instance of the OperationsHealthClient client. -func NewOperationsHealthClient(subscriptionID string) OperationsHealthClient { - return NewOperationsHealthClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsHealthClientWithBaseURI creates an instance of the OperationsHealthClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewOperationsHealthClientWithBaseURI(baseURI string, subscriptionID string) OperationsHealthClient { - return OperationsHealthClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListByLocation gets a service operation health status. -// Parameters: -// locationName - the name of the region where the resource is located. -func (client OperationsHealthClient) ListByLocation(ctx context.Context, locationName string) (result OperationsHealthListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthClient.ListByLocation") - defer func() { - sc := -1 - if result.ohlr.Response.Response != nil { - sc = result.ohlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listByLocationNextResults - req, err := client.ListByLocationPreparer(ctx, locationName) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "ListByLocation", nil, "Failure preparing request") - return - } - - resp, err := client.ListByLocationSender(req) - if err != nil { - result.ohlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "ListByLocation", resp, "Failure sending request") - return - } - - result.ohlr, err = client.ListByLocationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "ListByLocation", resp, "Failure responding to request") - return - } - if result.ohlr.hasNextLink() && result.ohlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByLocationPreparer prepares the ListByLocation request. -func (client OperationsHealthClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "locationName": autorest.Encode("path", locationName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2020-11-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/operationsHealth", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByLocationSender sends the ListByLocation request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsHealthClient) ListByLocationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByLocationResponder handles the response to the ListByLocation request. The method always -// closes the http.Response Body. -func (client OperationsHealthClient) ListByLocationResponder(resp *http.Response) (result OperationsHealthListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByLocationNextResults retrieves the next set of results, if any. -func (client OperationsHealthClient) listByLocationNextResults(ctx context.Context, lastResults OperationsHealthListResult) (result OperationsHealthListResult, err error) { - req, err := lastResults.operationsHealthListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "listByLocationNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByLocationSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "listByLocationNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByLocationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "listByLocationNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsHealthClient) ListByLocationComplete(ctx context.Context, locationName string) (result OperationsHealthListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthClient.ListByLocation") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListByLocation(ctx, locationName) - return -} diff --git a/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go b/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go index 60c0723d451a..efe7f24705e6 100644 --- a/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go +++ b/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go @@ -33,13 +33,12 @@ func NewReplicationLinksClientWithBaseURI(baseURI string, subscriptionID string) return ReplicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Delete deletes a database replication link. Cannot be done during failover. +// Delete deletes the replication link. // Parameters: // resourceGroupName - 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 - the name of the server. -// databaseName - the name of the database that has the replication link to be dropped. -// linkID - the ID of the replication link to be deleted. +// databaseName - the name of the database. func (client ReplicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Delete") @@ -83,7 +82,7 @@ func (client ReplicationLinksClient) DeletePreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -107,19 +106,19 @@ func (client ReplicationLinksClient) DeleteSender(req *http.Request) (*http.Resp func (client ReplicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByClosing()) result.Response = resp return } -// Failover sets which replica database is primary by failing over from the current primary replica database. +// Failover fails over from the current primary server to this server. // Parameters: // resourceGroupName - 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 - the name of the server. -// databaseName - the name of the database that has the replication link to be failed over. -// linkID - the ID of the replication link to be failed over. +// databaseName - the name of the database. +// linkID - the name of the replication link. func (client ReplicationLinksClient) Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Failover") @@ -156,7 +155,7 @@ func (client ReplicationLinksClient) FailoverPreparer(ctx context.Context, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -187,23 +186,23 @@ func (client ReplicationLinksClient) FailoverSender(req *http.Request) (future R // FailoverResponder handles the response to the Failover request. The method always // closes the http.Response Body. -func (client ReplicationLinksClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ReplicationLinksClient) FailoverResponder(resp *http.Response) (result ReplicationLink, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } -// FailoverAllowDataLoss sets which replica database is primary by failing over from the current primary replica -// database. This operation might result in data loss. +// FailoverAllowDataLoss fails over from the current primary server to this server allowing data loss. // Parameters: // resourceGroupName - 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 - the name of the server. -// databaseName - the name of the database that has the replication link to be failed over. -// linkID - the ID of the replication link to be failed over. +// databaseName - the name of the database. +// linkID - the name of the replication link. func (client ReplicationLinksClient) FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverAllowDataLossFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.FailoverAllowDataLoss") @@ -240,7 +239,7 @@ func (client ReplicationLinksClient) FailoverAllowDataLossPreparer(ctx context.C "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -271,12 +270,13 @@ func (client ReplicationLinksClient) FailoverAllowDataLossSender(req *http.Reque // FailoverAllowDataLossResponder handles the response to the FailoverAllowDataLoss request. The method always // closes the http.Response Body. -func (client ReplicationLinksClient) FailoverAllowDataLossResponder(resp *http.Response) (result autorest.Response, err error) { +func (client ReplicationLinksClient) FailoverAllowDataLossResponder(resp *http.Response) (result ReplicationLink, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) - result.Response = resp + result.Response = autorest.Response{Response: resp} return } @@ -330,7 +330,7 @@ func (client ReplicationLinksClient) GetPreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -414,7 +414,7 @@ func (client ReplicationLinksClient) ListByDatabasePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -533,7 +533,7 @@ func (client ReplicationLinksClient) ListByServerPreparer(ctx context.Context, r "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -600,89 +600,3 @@ func (client ReplicationLinksClient) ListByServerComplete(ctx context.Context, r result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) return } - -// Unlink deletes a database replication link in forced or friendly way. -// Parameters: -// resourceGroupName - 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 - the name of the server. -// databaseName - the name of the database that has the replication link to be failed over. -// linkID - the ID of the replication link to be failed over. -// parameters - the required parameters for unlinking replication link. -func (client ReplicationLinksClient) Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (result ReplicationLinksUnlinkFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Unlink") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UnlinkPreparer(ctx, resourceGroupName, serverName, databaseName, linkID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", nil, "Failure preparing request") - return - } - - result, err = client.UnlinkSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", result.Response(), "Failure sending request") - return - } - - return -} - -// UnlinkPreparer prepares the Unlink request. -func (client ReplicationLinksClient) UnlinkPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "databaseName": autorest.Encode("path", databaseName), - "linkId": autorest.Encode("path", linkID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "serverName": autorest.Encode("path", serverName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2014-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UnlinkSender sends the Unlink request. The method will close the -// http.Response Body if it receives an error. -func (client ReplicationLinksClient) UnlinkSender(req *http.Request) (future ReplicationLinksUnlinkFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UnlinkResponder handles the response to the Unlink request. The method always -// closes the http.Response Body. -func (client ReplicationLinksClient) UnlinkResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} diff --git a/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go b/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go index fba3a6c7ac5b..4e9f1e488849 100644 --- a/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go +++ b/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go @@ -80,7 +80,7 @@ func (client RestorableDroppedDatabasesClient) GetPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -162,7 +162,7 @@ func (client RestorableDroppedDatabasesClient) ListByServerPreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go b/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go index 0758769aae6d..2d9de035e999 100644 --- a/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go +++ b/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go @@ -81,7 +81,7 @@ func (client RestorableDroppedManagedDatabasesClient) GetPreparer(ctx context.Co "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -163,7 +163,7 @@ func (client RestorableDroppedManagedDatabasesClient) ListByInstancePreparer(ctx "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2021-02-01-preview" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/serveradvancedthreatprotectionsettings.go b/services/preview/sql/mgmt/v5.0/sql/serveradvancedthreatprotectionsettings.go new file mode 100644 index 000000000000..30a8a82fa6e0 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serveradvancedthreatprotectionsettings.go @@ -0,0 +1,317 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerAdvancedThreatProtectionSettingsClient 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 ServerAdvancedThreatProtectionSettingsClient struct { + BaseClient +} + +// NewServerAdvancedThreatProtectionSettingsClient creates an instance of the +// ServerAdvancedThreatProtectionSettingsClient client. +func NewServerAdvancedThreatProtectionSettingsClient(subscriptionID string) ServerAdvancedThreatProtectionSettingsClient { + return NewServerAdvancedThreatProtectionSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAdvancedThreatProtectionSettingsClientWithBaseURI creates an instance of the +// ServerAdvancedThreatProtectionSettingsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerAdvancedThreatProtectionSettingsClientWithBaseURI(baseURI string, subscriptionID string) ServerAdvancedThreatProtectionSettingsClient { + return ServerAdvancedThreatProtectionSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an Advanced Threat Protection state. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// parameters - the server Advanced Threat Protection state. +func (client ServerAdvancedThreatProtectionSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAdvancedThreatProtection) (result ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvancedThreatProtectionSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerAdvancedThreatProtectionSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAdvancedThreatProtection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advancedThreatProtectionName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", 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 ServerAdvancedThreatProtectionSettingsClient) CreateOrUpdateSender(req *http.Request) (future ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAdvancedThreatProtectionSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAdvancedThreatProtection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a server's Advanced Threat Protection state. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAdvancedThreatProtectionSettingsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAdvancedThreatProtection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvancedThreatProtectionSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "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.ServerAdvancedThreatProtectionSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAdvancedThreatProtectionSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advancedThreatProtectionName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", 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 ServerAdvancedThreatProtectionSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAdvancedThreatProtectionSettingsClient) GetResponder(resp *http.Response) (result ServerAdvancedThreatProtection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer get a list of the server's Advanced Threat Protection states. +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerAdvancedThreatProtectionSettingsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result LogicalServerAdvancedThreatProtectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvancedThreatProtectionSettingsClient.ListByServer") + defer func() { + sc := -1 + if result.lsatplr.Response.Response != nil { + sc = result.lsatplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.lsatplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.lsatplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.lsatplr.hasNextLink() && result.lsatplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAdvancedThreatProtectionSettingsClient) 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 = "2021-11-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}/advancedThreatProtectionSettings", 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 ServerAdvancedThreatProtectionSettingsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAdvancedThreatProtectionSettingsClient) ListByServerResponder(resp *http.Response) (result LogicalServerAdvancedThreatProtectionListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerAdvancedThreatProtectionSettingsClient) listByServerNextResults(ctx context.Context, lastResults LogicalServerAdvancedThreatProtectionListResult) (result LogicalServerAdvancedThreatProtectionListResult, err error) { + req, err := lastResults.logicalServerAdvancedThreatProtectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "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.ServerAdvancedThreatProtectionSettingsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvancedThreatProtectionSettingsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerAdvancedThreatProtectionSettingsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result LogicalServerAdvancedThreatProtectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvancedThreatProtectionSettingsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go index 377ee039e237..8045da02aaf9 100644 --- a/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go @@ -74,7 +74,7 @@ func (client ServerBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -164,7 +164,7 @@ func (client ServerBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -246,7 +246,7 @@ func (client ServerBlobAuditingPoliciesClient) ListByServerPreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2020-11-01-preview" + const APIVersion = "2021-11-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go index fd714db39b75..416550161475 100644 --- a/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go +++ b/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go @@ -33,19 +33,19 @@ func NewServerConnectionPoliciesClientWithBaseURI(baseURI string, subscriptionID return ServerConnectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates or updates the server's connection policy. +// CreateOrUpdate updates a server connection policy // Parameters: // resourceGroupName - 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 - the name of the server. -// parameters - the required parameters for updating a secure connection policy. -func (client ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (result ServerConnectionPolicy, err error) { +// parameters - the required parameters for updating a server connection policy. +func (client ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (result ServerConnectionPoliciesCreateOrUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.CreateOrUpdate") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -56,16 +56,9 @@ func (client ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, return } - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) + result, err = client.CreateOrUpdateSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } @@ -81,13 +74,13 @@ func (client ServerConnectionPoliciesClient) CreateOrUpdatePreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } - parameters.Kind = nil parameters.Location = nil + parameters.Kind = nil preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), @@ -100,8 +93,18 @@ func (client ServerConnectionPoliciesClient) CreateOrUpdatePreparer(ctx context. // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. -func (client ServerConnectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +func (client ServerConnectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerConnectionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return } // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always @@ -109,14 +112,14 @@ func (client ServerConnectionPoliciesClient) CreateOrUpdateSender(req *http.Requ func (client ServerConnectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } -// Get gets the server's secure connection policy. +// Get gets a server connection policy // Parameters: // resourceGroupName - the name of the resource group that contains the resource. You can obtain this value // from the Azure Resource Manager API or the portal. @@ -163,7 +166,7 @@ func (client ServerConnectionPoliciesClient) GetPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-05-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -193,3 +196,122 @@ func (client ServerConnectionPoliciesClient) GetResponder(resp *http.Response) ( result.Response = autorest.Response{Response: resp} return } + +// ListByServer lists connection policy +// Parameters: +// resourceGroupName - 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 - the name of the server. +func (client ServerConnectionPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.scplr.Response.Response != nil { + sc = result.scplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.scplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.scplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.scplr.hasNextLink() && result.scplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerConnectionPoliciesClient) 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 = "2021-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}/connectionPolicies", 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 ServerConnectionPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) ListByServerResponder(resp *http.Response) (result ServerConnectionPolicyListResult, err error) { + err = autorest.Respond( + resp, + 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 ServerConnectionPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ServerConnectionPolicyListResult) (result ServerConnectionPolicyListResult, err error) { + req, err := lastResults.serverConnectionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "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.ServerConnectionPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerConnectionPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/servertrustcertificates.go b/services/preview/sql/mgmt/v5.0/sql/servertrustcertificates.go new file mode 100644 index 000000000000..d0f4a1495ae2 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/servertrustcertificates.go @@ -0,0 +1,399 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// 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/tracing" + "net/http" +) + +// ServerTrustCertificatesClient 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 ServerTrustCertificatesClient struct { + BaseClient +} + +// NewServerTrustCertificatesClient creates an instance of the ServerTrustCertificatesClient client. +func NewServerTrustCertificatesClient(subscriptionID string) ServerTrustCertificatesClient { + return NewServerTrustCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerTrustCertificatesClientWithBaseURI creates an instance of the ServerTrustCertificatesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewServerTrustCertificatesClientWithBaseURI(baseURI string, subscriptionID string) ServerTrustCertificatesClient { + return ServerTrustCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate uploads a server trust certificate from box to Sql Managed Instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// certificateName - name of of the certificate to upload. +// parameters - the server trust certificate info. +func (client ServerTrustCertificatesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string, parameters ServerTrustCertificate) (result ServerTrustCertificatesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, certificateName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerTrustCertificatesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string, parameters ServerTrustCertificate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}", 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 ServerTrustCertificatesClient) CreateOrUpdateSender(req *http.Request) (future ServerTrustCertificatesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerTrustCertificatesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerTrustCertificate, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server trust certificate that was uploaded from box to Sql Managed Instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// certificateName - name of of the certificate to delete. +func (client ServerTrustCertificatesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string) (result ServerTrustCertificatesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerTrustCertificatesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}", 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 ServerTrustCertificatesClient) DeleteSender(req *http.Request) (future ServerTrustCertificatesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerTrustCertificatesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server trust certificate that was uploaded from box to Sql Managed Instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// certificateName - name of of the certificate to get. +func (client ServerTrustCertificatesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string) (result ServerTrustCertificate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, certificateName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "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.ServerTrustCertificatesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerTrustCertificatesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}", 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 ServerTrustCertificatesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerTrustCertificatesClient) GetResponder(resp *http.Response) (result ServerTrustCertificate, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of server trust certificates that were uploaded from box to the given Sql Managed +// Instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ServerTrustCertificatesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ServerTrustCertificatesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesClient.ListByInstance") + defer func() { + sc := -1 + if result.stclr.Response.Response != nil { + sc = result.stclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.stclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.stclr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.stclr.hasNextLink() && result.stclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ServerTrustCertificatesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-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/managedInstances/{managedInstanceName}/serverTrustCertificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustCertificatesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ServerTrustCertificatesClient) ListByInstanceResponder(resp *http.Response) (result ServerTrustCertificatesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ServerTrustCertificatesClient) listByInstanceNextResults(ctx context.Context, lastResults ServerTrustCertificatesListResult) (result ServerTrustCertificatesListResult, err error) { + req, err := lastResults.serverTrustCertificatesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustCertificatesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerTrustCertificatesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ServerTrustCertificatesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustCertificatesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go index c0309960fd04..c61dae19eb14 100644 --- a/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go +++ b/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go @@ -22,14 +22,6 @@ type RecoverableDatabasesClientAPI interface { var _ RecoverableDatabasesClientAPI = (*sql.RecoverableDatabasesClient)(nil) -// ServerConnectionPoliciesClientAPI contains the set of methods on the ServerConnectionPoliciesClient type. -type ServerConnectionPoliciesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerConnectionPolicy) (result sql.ServerConnectionPolicy, err error) - Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicy, err error) -} - -var _ ServerConnectionPoliciesClientAPI = (*sql.ServerConnectionPoliciesClient)(nil) - // DataMaskingPoliciesClientAPI contains the set of methods on the DataMaskingPoliciesClient type. type DataMaskingPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DataMaskingPolicy) (result sql.DataMaskingPolicy, err error) @@ -86,8 +78,8 @@ type ElasticPoolsClientAPI interface { Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsDeleteFuture, err error) Failover(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsFailoverFuture, err error) Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPool, err error) - ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultPage, err error) - ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultIterator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int64) (result sql.ElasticPoolListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int64) (result sql.ElasticPoolListResultIterator, err error) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.MetricDefinitionListResult, err error) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result sql.MetricListResult, err error) Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPoolUpdate) (result sql.ElasticPoolsUpdateFuture, err error) @@ -95,21 +87,6 @@ type ElasticPoolsClientAPI interface { var _ ElasticPoolsClientAPI = (*sql.ElasticPoolsClient)(nil) -// ReplicationLinksClientAPI contains the set of methods on the ReplicationLinksClient type. -type ReplicationLinksClientAPI interface { - Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) - Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverFuture, err error) - FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverAllowDataLossFuture, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLink, err error) - ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResultIterator, err error) - ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ReplicationLinkListResultPage, err error) - ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ReplicationLinkListResultIterator, err error) - Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters sql.UnlinkParameters) (result sql.ReplicationLinksUnlinkFuture, err error) -} - -var _ ReplicationLinksClientAPI = (*sql.ReplicationLinksClient)(nil) - // ServerCommunicationLinksClientAPI contains the set of methods on the ServerCommunicationLinksClient type. type ServerCommunicationLinksClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters sql.ServerCommunicationLink) (result sql.ServerCommunicationLinksCreateOrUpdateFuture, err error) @@ -142,21 +119,6 @@ type ElasticPoolDatabaseActivitiesClientAPI interface { var _ ElasticPoolDatabaseActivitiesClientAPI = (*sql.ElasticPoolDatabaseActivitiesClient)(nil) -// TransparentDataEncryptionsClientAPI contains the set of methods on the TransparentDataEncryptionsClient type. -type TransparentDataEncryptionsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.TransparentDataEncryption) (result sql.TransparentDataEncryption, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryption, err error) -} - -var _ TransparentDataEncryptionsClientAPI = (*sql.TransparentDataEncryptionsClient)(nil) - -// TransparentDataEncryptionActivitiesClientAPI contains the set of methods on the TransparentDataEncryptionActivitiesClient type. -type TransparentDataEncryptionActivitiesClientAPI interface { - ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryptionActivityListResult, err error) -} - -var _ TransparentDataEncryptionActivitiesClientAPI = (*sql.TransparentDataEncryptionActivitiesClient)(nil) - // ServerUsagesClientAPI contains the set of methods on the ServerUsagesClient type. type ServerUsagesClientAPI interface { ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerUsageListResult, err error) @@ -164,46 +126,6 @@ type ServerUsagesClientAPI interface { var _ ServerUsagesClientAPI = (*sql.ServerUsagesClient)(nil) -// ExtendedDatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedDatabaseBlobAuditingPoliciesClient type. -type ExtendedDatabaseBlobAuditingPoliciesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExtendedDatabaseBlobAuditingPolicy) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) - ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultIterator, err error) -} - -var _ ExtendedDatabaseBlobAuditingPoliciesClientAPI = (*sql.ExtendedDatabaseBlobAuditingPoliciesClient)(nil) - -// ExtendedServerBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedServerBlobAuditingPoliciesClient type. -type ExtendedServerBlobAuditingPoliciesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ExtendedServerBlobAuditingPolicy) (result sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) - Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicy, err error) - ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultPage, err error) - ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultIterator, err error) -} - -var _ ExtendedServerBlobAuditingPoliciesClientAPI = (*sql.ExtendedServerBlobAuditingPoliciesClient)(nil) - -// ServerBlobAuditingPoliciesClientAPI contains the set of methods on the ServerBlobAuditingPoliciesClient type. -type ServerBlobAuditingPoliciesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerBlobAuditingPolicy) (result sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) - Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicy, err error) - ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultPage, err error) - ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultIterator, err error) -} - -var _ ServerBlobAuditingPoliciesClientAPI = (*sql.ServerBlobAuditingPoliciesClient)(nil) - -// DatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the DatabaseBlobAuditingPoliciesClient type. -type DatabaseBlobAuditingPoliciesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseBlobAuditingPolicy) (result sql.DatabaseBlobAuditingPolicy, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicy, err error) - ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultIterator, err error) -} - -var _ DatabaseBlobAuditingPoliciesClientAPI = (*sql.DatabaseBlobAuditingPoliciesClient)(nil) - // DatabaseAdvisorsClientAPI contains the set of methods on the DatabaseAdvisorsClient type. type DatabaseAdvisorsClientAPI interface { Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (result sql.Advisor, err error) @@ -503,54 +425,6 @@ type CapabilitiesClientAPI interface { var _ CapabilitiesClientAPI = (*sql.CapabilitiesClient)(nil) -// LongTermRetentionBackupsClientAPI contains the set of methods on the LongTermRetentionBackupsClient type. -type LongTermRetentionBackupsClientAPI interface { - Copy(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyFuture, err error) - CopyByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyByResourceGroupFuture, err error) - Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteFuture, err error) - DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) - Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) - GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) - ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) - ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) - Update(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateFuture, err error) - UpdateByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) -} - -var _ LongTermRetentionBackupsClientAPI = (*sql.LongTermRetentionBackupsClient)(nil) - -// LongTermRetentionManagedInstanceBackupsClientAPI contains the set of methods on the LongTermRetentionManagedInstanceBackupsClient type. -type LongTermRetentionManagedInstanceBackupsClientAPI interface { - Delete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) - DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) - Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) - GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) - ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) - ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) - ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) -} - -var _ LongTermRetentionManagedInstanceBackupsClientAPI = (*sql.LongTermRetentionManagedInstanceBackupsClient)(nil) - // LongTermRetentionPoliciesClientAPI contains the set of methods on the LongTermRetentionPoliciesClient type. type LongTermRetentionPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LongTermRetentionPolicy) (result sql.LongTermRetentionPoliciesCreateOrUpdateFuture, err error) @@ -656,29 +530,6 @@ type ManagedDatabaseSecurityEventsClientAPI interface { var _ ManagedDatabaseSecurityEventsClientAPI = (*sql.ManagedDatabaseSecurityEventsClient)(nil) -// ManagedDatabaseSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseSensitivityLabelsClient type. -type ManagedDatabaseSensitivityLabelsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) - Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) - DisableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) - EnableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) - Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) - ListCurrentByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) - ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) - ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) - ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) - Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.SensitivityLabelUpdateList) (result autorest.Response, err error) -} - -var _ ManagedDatabaseSensitivityLabelsClientAPI = (*sql.ManagedDatabaseSensitivityLabelsClient)(nil) - -// ManagedDatabaseRecommendedSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseRecommendedSensitivityLabelsClient type. -type ManagedDatabaseRecommendedSensitivityLabelsClientAPI interface { - Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) -} - -var _ ManagedDatabaseRecommendedSensitivityLabelsClientAPI = (*sql.ManagedDatabaseRecommendedSensitivityLabelsClient)(nil) - // ManagedDatabaseTablesClientAPI contains the set of methods on the ManagedDatabaseTablesClient type. type ManagedDatabaseTablesClientAPI interface { Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string) (result sql.DatabaseTable, err error) @@ -813,25 +664,6 @@ type ManagedInstancePrivateLinkResourcesClientAPI interface { var _ ManagedInstancePrivateLinkResourcesClientAPI = (*sql.ManagedInstancePrivateLinkResourcesClient)(nil) -// ManagedInstancesClientAPI contains the set of methods on the ManagedInstancesClient type. -type ManagedInstancesClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstance) (result sql.ManagedInstancesCreateOrUpdateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancesDeleteFuture, err error) - Failover(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType sql.ReplicaType) (result sql.ManagedInstancesFailoverFuture, err error) - Get(ctx context.Context, resourceGroupName string, managedInstanceName string, expand string) (result sql.ManagedInstance, err error) - List(ctx context.Context, expand string) (result sql.ManagedInstanceListResultPage, err error) - ListComplete(ctx context.Context, expand string) (result sql.ManagedInstanceListResultIterator, err error) - ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result sql.ManagedInstanceListResultPage, err error) - ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result sql.ManagedInstanceListResultIterator, err error) - ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultPage, err error) - ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultIterator, err error) - ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result sql.ManagedInstanceListResultPage, err error) - ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result sql.ManagedInstanceListResultIterator, err error) - Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceUpdate) (result sql.ManagedInstancesUpdateFuture, err error) -} - -var _ ManagedInstancesClientAPI = (*sql.ManagedInstancesClient)(nil) - // ManagedInstanceTdeCertificatesClientAPI contains the set of methods on the ManagedInstanceTdeCertificatesClient type. type ManagedInstanceTdeCertificatesClientAPI interface { Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.TdeCertificate) (result sql.ManagedInstanceTdeCertificatesCreateFuture, err error) @@ -879,14 +711,6 @@ type OperationsClientAPI interface { var _ OperationsClientAPI = (*sql.OperationsClient)(nil) -// OperationsHealthClientAPI contains the set of methods on the OperationsHealthClient type. -type OperationsHealthClientAPI interface { - ListByLocation(ctx context.Context, locationName string) (result sql.OperationsHealthListResultPage, err error) - ListByLocationComplete(ctx context.Context, locationName string) (result sql.OperationsHealthListResultIterator, err error) -} - -var _ OperationsHealthClientAPI = (*sql.OperationsHealthClient)(nil) - // PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. type PrivateEndpointConnectionsClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters sql.PrivateEndpointConnection) (result sql.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) @@ -927,29 +751,6 @@ type RestorePointsClientAPI interface { var _ RestorePointsClientAPI = (*sql.RestorePointsClient)(nil) -// SensitivityLabelsClientAPI contains the set of methods on the SensitivityLabelsClient type. -type SensitivityLabelsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) - Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) - DisableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) - EnableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) - Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) - ListCurrentByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) - ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) - ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) - ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) - Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.SensitivityLabelUpdateList) (result autorest.Response, err error) -} - -var _ SensitivityLabelsClientAPI = (*sql.SensitivityLabelsClient)(nil) - -// RecommendedSensitivityLabelsClientAPI contains the set of methods on the RecommendedSensitivityLabelsClient type. -type RecommendedSensitivityLabelsClientAPI interface { - Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) -} - -var _ RecommendedSensitivityLabelsClientAPI = (*sql.RecommendedSensitivityLabelsClient)(nil) - // ServerAdvisorsClientAPI contains the set of methods on the ServerAdvisorsClient type. type ServerAdvisorsClientAPI interface { Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (result sql.Advisor, err error) @@ -1105,8 +906,8 @@ type SyncGroupsClientAPI interface { ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultIterator, err error) ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) - ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultPage, err error) - ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultIterator, err error) + ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter sql.SyncGroupsType, continuationToken string) (result sql.SyncGroupLogListResultPage, err error) + ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter sql.SyncGroupsType, continuationToken string) (result sql.SyncGroupLogListResultIterator, err error) ListSyncDatabaseIds(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultPage, err error) ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultIterator, err error) RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsRefreshHubSchemaFuture, err error) @@ -1194,6 +995,16 @@ type WorkloadGroupsClientAPI interface { var _ WorkloadGroupsClientAPI = (*sql.WorkloadGroupsClient)(nil) +// TransparentDataEncryptionsClientAPI contains the set of methods on the TransparentDataEncryptionsClient type. +type TransparentDataEncryptionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LogicalDatabaseTransparentDataEncryption) (result sql.LogicalDatabaseTransparentDataEncryption, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LogicalDatabaseTransparentDataEncryption, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LogicalDatabaseTransparentDataEncryptionListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LogicalDatabaseTransparentDataEncryptionListResultIterator, err error) +} + +var _ TransparentDataEncryptionsClientAPI = (*sql.TransparentDataEncryptionsClient)(nil) + // BackupShortTermRetentionPoliciesClientAPI contains the set of methods on the BackupShortTermRetentionPoliciesClient type. type BackupShortTermRetentionPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) @@ -1234,8 +1045,8 @@ var _ DatabaseUsagesClientAPI = (*sql.DatabaseUsagesClient)(nil) // LedgerDigestUploadsClientAPI contains the set of methods on the LedgerDigestUploadsClient type. type LedgerDigestUploadsClientAPI interface { - CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LedgerDigestUploads) (result sql.LedgerDigestUploads, err error) - Disable(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploads, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LedgerDigestUploads) (result sql.LedgerDigestUploadsCreateOrUpdateFuture, err error) + Disable(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploadsDisableFuture, err error) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploads, err error) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploadsListResultPage, err error) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploadsListResultIterator, err error) @@ -1254,24 +1065,6 @@ type OutboundFirewallRulesClientAPI interface { var _ OutboundFirewallRulesClientAPI = (*sql.OutboundFirewallRulesClient)(nil) -// RestorableDroppedDatabasesClientAPI contains the set of methods on the RestorableDroppedDatabasesClient type. -type RestorableDroppedDatabasesClientAPI interface { - Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedDatabase, err error) - ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResultPage, err error) - ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResultIterator, err error) -} - -var _ RestorableDroppedDatabasesClientAPI = (*sql.RestorableDroppedDatabasesClient)(nil) - -// RestorableDroppedManagedDatabasesClientAPI contains the set of methods on the RestorableDroppedManagedDatabasesClient type. -type RestorableDroppedManagedDatabasesClientAPI interface { - Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedManagedDatabase, err error) - ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultPage, err error) - ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultIterator, err error) -} - -var _ RestorableDroppedManagedDatabasesClientAPI = (*sql.RestorableDroppedManagedDatabasesClient)(nil) - // ServersClientAPI contains the set of methods on the ServersClient type. type ServersClientAPI interface { CheckNameAvailability(ctx context.Context, parameters sql.CheckNameAvailabilityRequest) (result sql.CheckNameAvailabilityResponse, err error) @@ -1295,3 +1088,273 @@ type UsagesClientAPI interface { } var _ UsagesClientAPI = (*sql.UsagesClient)(nil) + +// LongTermRetentionBackupsClientAPI contains the set of methods on the LongTermRetentionBackupsClient type. +type LongTermRetentionBackupsClientAPI interface { + Copy(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyFuture, err error) + CopyByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyByResourceGroupFuture, err error) + Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + Update(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateFuture, err error) + UpdateByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) +} + +var _ LongTermRetentionBackupsClientAPI = (*sql.LongTermRetentionBackupsClient)(nil) + +// LongTermRetentionManagedInstanceBackupsClientAPI contains the set of methods on the LongTermRetentionManagedInstanceBackupsClient type. +type LongTermRetentionManagedInstanceBackupsClientAPI interface { + Delete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) +} + +var _ LongTermRetentionManagedInstanceBackupsClientAPI = (*sql.LongTermRetentionManagedInstanceBackupsClient)(nil) + +// ManagedInstancesClientAPI contains the set of methods on the ManagedInstancesClient type. +type ManagedInstancesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstance) (result sql.ManagedInstancesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancesDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType sql.ReplicaType) (result sql.ManagedInstancesFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, expand string) (result sql.ManagedInstance, err error) + List(ctx context.Context, expand string) (result sql.ManagedInstanceListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result sql.ManagedInstanceListResultIterator, err error) + ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result sql.ManagedInstanceListResultPage, err error) + ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result sql.ManagedInstanceListResultIterator, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result sql.ManagedInstanceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result sql.ManagedInstanceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceUpdate) (result sql.ManagedInstancesUpdateFuture, err error) +} + +var _ ManagedInstancesClientAPI = (*sql.ManagedInstancesClient)(nil) + +// RestorableDroppedDatabasesClientAPI contains the set of methods on the RestorableDroppedDatabasesClient type. +type RestorableDroppedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResultIterator, err error) +} + +var _ RestorableDroppedDatabasesClientAPI = (*sql.RestorableDroppedDatabasesClient)(nil) + +// RestorableDroppedManagedDatabasesClientAPI contains the set of methods on the RestorableDroppedManagedDatabasesClient type. +type RestorableDroppedManagedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultIterator, err error) +} + +var _ RestorableDroppedManagedDatabasesClientAPI = (*sql.RestorableDroppedManagedDatabasesClient)(nil) + +// ServerConnectionPoliciesClientAPI contains the set of methods on the ServerConnectionPoliciesClient type. +type ServerConnectionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerConnectionPolicy) (result sql.ServerConnectionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicyListResultIterator, err error) +} + +var _ ServerConnectionPoliciesClientAPI = (*sql.ServerConnectionPoliciesClient)(nil) + +// DistributedAvailabilityGroupsClientAPI contains the set of methods on the DistributedAvailabilityGroupsClient type. +type DistributedAvailabilityGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string, parameters sql.DistributedAvailabilityGroup) (result sql.DistributedAvailabilityGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string) (result sql.DistributedAvailabilityGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string) (result sql.DistributedAvailabilityGroup, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.DistributedAvailabilityGroupsListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.DistributedAvailabilityGroupsListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, distributedAvailabilityGroupName string, parameters sql.DistributedAvailabilityGroup) (result sql.DistributedAvailabilityGroupsUpdateFuture, err error) +} + +var _ DistributedAvailabilityGroupsClientAPI = (*sql.DistributedAvailabilityGroupsClient)(nil) + +// ServerTrustCertificatesClientAPI contains the set of methods on the ServerTrustCertificatesClient type. +type ServerTrustCertificatesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string, parameters sql.ServerTrustCertificate) (result sql.ServerTrustCertificatesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string) (result sql.ServerTrustCertificatesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, certificateName string) (result sql.ServerTrustCertificate, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ServerTrustCertificatesListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ServerTrustCertificatesListResultIterator, err error) +} + +var _ ServerTrustCertificatesClientAPI = (*sql.ServerTrustCertificatesClient)(nil) + +// IPv6FirewallRulesClientAPI contains the set of methods on the IPv6FirewallRulesClient type. +type IPv6FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters sql.IPv6FirewallRule) (result sql.IPv6FirewallRule, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result sql.IPv6FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.IPv6FirewallRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.IPv6FirewallRuleListResultIterator, err error) +} + +var _ IPv6FirewallRulesClientAPI = (*sql.IPv6FirewallRulesClient)(nil) + +// EndpointCertificatesClientAPI contains the set of methods on the EndpointCertificatesClient type. +type EndpointCertificatesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, endpointType string) (result sql.EndpointCertificate, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.EndpointCertificateListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.EndpointCertificateListResultIterator, err error) +} + +var _ EndpointCertificatesClientAPI = (*sql.EndpointCertificatesClient)(nil) + +// ReplicationLinksClientAPI contains the set of methods on the ReplicationLinksClient type. +type ReplicationLinksClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverFuture, err error) + FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLink, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResultIterator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ReplicationLinkListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ReplicationLinkListResultIterator, err error) +} + +var _ ReplicationLinksClientAPI = (*sql.ReplicationLinksClient)(nil) + +// ManagedDatabaseSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseSensitivityLabelsClient type. +type ManagedDatabaseSensitivityLabelsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + DisableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + EnableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) + ListCurrentByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.SensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ ManagedDatabaseSensitivityLabelsClientAPI = (*sql.ManagedDatabaseSensitivityLabelsClient)(nil) + +// ManagedDatabaseRecommendedSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseRecommendedSensitivityLabelsClient type. +type ManagedDatabaseRecommendedSensitivityLabelsClientAPI interface { + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ ManagedDatabaseRecommendedSensitivityLabelsClientAPI = (*sql.ManagedDatabaseRecommendedSensitivityLabelsClient)(nil) + +// SensitivityLabelsClientAPI contains the set of methods on the SensitivityLabelsClient type. +type SensitivityLabelsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + DisableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + EnableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) + ListCurrentByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.SensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ SensitivityLabelsClientAPI = (*sql.SensitivityLabelsClient)(nil) + +// RecommendedSensitivityLabelsClientAPI contains the set of methods on the RecommendedSensitivityLabelsClient type. +type RecommendedSensitivityLabelsClientAPI interface { + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ RecommendedSensitivityLabelsClientAPI = (*sql.RecommendedSensitivityLabelsClient)(nil) + +// ServerBlobAuditingPoliciesClientAPI contains the set of methods on the ServerBlobAuditingPoliciesClient type. +type ServerBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerBlobAuditingPolicy) (result sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultIterator, err error) +} + +var _ ServerBlobAuditingPoliciesClientAPI = (*sql.ServerBlobAuditingPoliciesClient)(nil) + +// DatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the DatabaseBlobAuditingPoliciesClient type. +type DatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseBlobAuditingPolicy) (result sql.DatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ DatabaseBlobAuditingPoliciesClientAPI = (*sql.DatabaseBlobAuditingPoliciesClient)(nil) + +// ExtendedDatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedDatabaseBlobAuditingPoliciesClient type. +type ExtendedDatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExtendedDatabaseBlobAuditingPolicy) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ ExtendedDatabaseBlobAuditingPoliciesClientAPI = (*sql.ExtendedDatabaseBlobAuditingPoliciesClient)(nil) + +// ExtendedServerBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedServerBlobAuditingPoliciesClient type. +type ExtendedServerBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ExtendedServerBlobAuditingPolicy) (result sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultIterator, err error) +} + +var _ ExtendedServerBlobAuditingPoliciesClientAPI = (*sql.ExtendedServerBlobAuditingPoliciesClient)(nil) + +// DatabaseAdvancedThreatProtectionSettingsClientAPI contains the set of methods on the DatabaseAdvancedThreatProtectionSettingsClient type. +type DatabaseAdvancedThreatProtectionSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseAdvancedThreatProtection) (result sql.DatabaseAdvancedThreatProtection, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseAdvancedThreatProtection, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseAdvancedThreatProtectionListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseAdvancedThreatProtectionListResultIterator, err error) +} + +var _ DatabaseAdvancedThreatProtectionSettingsClientAPI = (*sql.DatabaseAdvancedThreatProtectionSettingsClient)(nil) + +// ServerAdvancedThreatProtectionSettingsClientAPI contains the set of methods on the ServerAdvancedThreatProtectionSettingsClient type. +type ServerAdvancedThreatProtectionSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAdvancedThreatProtection) (result sql.ServerAdvancedThreatProtectionSettingsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAdvancedThreatProtection, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.LogicalServerAdvancedThreatProtectionListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.LogicalServerAdvancedThreatProtectionListResultIterator, err error) +} + +var _ ServerAdvancedThreatProtectionSettingsClientAPI = (*sql.ServerAdvancedThreatProtectionSettingsClient)(nil) + +// ManagedServerDNSAliasesClientAPI contains the set of methods on the ManagedServerDNSAliasesClient type. +type ManagedServerDNSAliasesClientAPI interface { + Acquire(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string, parameters sql.ManagedServerDNSAliasAcquisition) (result sql.ManagedServerDNSAliasesAcquireFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string, parameters sql.ManagedServerDNSAliasCreation) (result sql.ManagedServerDNSAliasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string) (result sql.ManagedServerDNSAliasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, DNSAliasName string) (result sql.ManagedServerDNSAlias, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerDNSAliasListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerDNSAliasListResultIterator, err error) +} + +var _ ManagedServerDNSAliasesClientAPI = (*sql.ManagedServerDNSAliasesClient)(nil) diff --git a/services/preview/sql/mgmt/v5.0/sql/syncgroups.go b/services/preview/sql/mgmt/v5.0/sql/syncgroups.go index e8fbad895e04..0d388e00ce91 100644 --- a/services/preview/sql/mgmt/v5.0/sql/syncgroups.go +++ b/services/preview/sql/mgmt/v5.0/sql/syncgroups.go @@ -626,7 +626,7 @@ func (client SyncGroupsClient) ListHubSchemasComplete(ctx context.Context, resou // endTime - get logs generated before this time. // typeParameter - the types of logs to retrieve. // continuationToken - the continuation token for this operation. -func (client SyncGroupsClient) ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultPage, err error) { +func (client SyncGroupsClient) ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter SyncGroupsType, continuationToken string) (result SyncGroupLogListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") defer func() { @@ -665,7 +665,7 @@ func (client SyncGroupsClient) ListLogs(ctx context.Context, resourceGroupName s } // ListLogsPreparer prepares the ListLogs request. -func (client SyncGroupsClient) ListLogsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (*http.Request, error) { +func (client SyncGroupsClient) ListLogsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter SyncGroupsType, continuationToken string) (*http.Request, error) { pathParameters := map[string]interface{}{ "databaseName": autorest.Encode("path", databaseName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -733,7 +733,7 @@ func (client SyncGroupsClient) listLogsNextResults(ctx context.Context, lastResu } // ListLogsComplete enumerates all values, automatically crossing page boundaries as required. -func (client SyncGroupsClient) ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultIterator, err error) { +func (client SyncGroupsClient) ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter SyncGroupsType, continuationToken string) (result SyncGroupLogListResultIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") defer func() { diff --git a/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go b/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go index 691b41cd1464..79f9d00ca5a6 100644 --- a/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go +++ b/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go @@ -33,14 +33,14 @@ func NewTransparentDataEncryptionsClientWithBaseURI(baseURI string, subscription return TransparentDataEncryptionsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate creates or updates a database's transparent data encryption configuration. +// CreateOrUpdate updates a logical database's transparent data encryption configuration. // Parameters: // resourceGroupName - 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 - the name of the server. -// databaseName - the name of the database for which setting the transparent data encryption applies. -// parameters - the required parameters for creating or updating transparent data encryption. -func (client TransparentDataEncryptionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (result TransparentDataEncryption, err error) { +// databaseName - the name of the logical database for which the security alert policy is defined. +// parameters - the database transparent data encryption. +func (client TransparentDataEncryptionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LogicalDatabaseTransparentDataEncryption) (result LogicalDatabaseTransparentDataEncryption, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.CreateOrUpdate") defer func() { @@ -74,26 +74,25 @@ func (client TransparentDataEncryptionsClient) CreateOrUpdate(ctx context.Contex } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client TransparentDataEncryptionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (*http.Request, error) { +func (client TransparentDataEncryptionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LogicalDatabaseTransparentDataEncryption) (*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), - "transparentDataEncryptionName": autorest.Encode("path", "current"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tdeName": autorest.Encode("path", "current"), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-02-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } - parameters.Location = nil preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", pathParameters), autorest.WithJSON(parameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -107,23 +106,23 @@ func (client TransparentDataEncryptionsClient) CreateOrUpdateSender(req *http.Re // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. -func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result TransparentDataEncryption, err error) { +func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result LogicalDatabaseTransparentDataEncryption, err error) { err = autorest.Respond( resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } -// Get gets a database's transparent data encryption configuration. +// Get gets a logical database's transparent data encryption. // Parameters: // resourceGroupName - 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 - the name of the server. -// databaseName - the name of the database for which the transparent data encryption applies. -func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { +// databaseName - the name of the logical database for which the transparent data encryption is defined. +func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LogicalDatabaseTransparentDataEncryption, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.Get") defer func() { @@ -159,14 +158,14 @@ func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resource // GetPreparer prepares the Get request. func (client TransparentDataEncryptionsClient) 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), - "transparentDataEncryptionName": autorest.Encode("path", "current"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tdeName": autorest.Encode("path", "current"), } - const APIVersion = "2014-04-01" + const APIVersion = "2021-02-01-preview" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -174,7 +173,7 @@ func (client TransparentDataEncryptionsClient) GetPreparer(ctx context.Context, preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -187,7 +186,7 @@ func (client TransparentDataEncryptionsClient) GetSender(req *http.Request) (*ht // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. -func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result TransparentDataEncryption, err error) { +func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result LogicalDatabaseTransparentDataEncryption, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK), @@ -196,3 +195,124 @@ func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) result.Response = autorest.Response{Response: resp} return } + +// ListByDatabase gets a list of the logical database's transparent data encryption. +// Parameters: +// resourceGroupName - 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 - the name of the server. +// databaseName - the name of the logical database for which the transparent data encryption is defined. +func (client TransparentDataEncryptionsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LogicalDatabaseTransparentDataEncryptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.ListByDatabase") + defer func() { + sc := -1 + if result.ldtdelr.Response.Response != nil { + sc = result.ldtdelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ldtdelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ldtdelr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ldtdelr.hasNextLink() && result.ldtdelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client TransparentDataEncryptionsClient) ListByDatabasePreparer(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 = "2021-02-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}/transparentDataEncryption", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client TransparentDataEncryptionsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) ListByDatabaseResponder(resp *http.Response) (result LogicalDatabaseTransparentDataEncryptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client TransparentDataEncryptionsClient) listByDatabaseNextResults(ctx context.Context, lastResults LogicalDatabaseTransparentDataEncryptionListResult) (result LogicalDatabaseTransparentDataEncryptionListResult, err error) { + req, err := lastResults.logicalDatabaseTransparentDataEncryptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransparentDataEncryptionsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LogicalDatabaseTransparentDataEncryptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/sql/mgmt/2014-04-01/sql/CHANGELOG.md b/services/sql/mgmt/2014-04-01/sql/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/sql/mgmt/2014-04-01/sql/CHANGELOG.md +++ b/services/sql/mgmt/2014-04-01/sql/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/sql/mgmt/2014-04-01/sql/_meta.json b/services/sql/mgmt/2014-04-01/sql/_meta.json index 062071db058d..1f05065e63b8 100644 --- a/services/sql/mgmt/2014-04-01/sql/_meta.json +++ b/services/sql/mgmt/2014-04-01/sql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9", "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", "tag": "package-pure-2014-04", "use": "@microsoft.azure/autorest.go@2.1.187",