diff --git a/profiles/preview/preview/sql/mgmt/sql/models.go b/profiles/preview/preview/sql/mgmt/sql/models.go new file mode 100644 index 000000000000..abcfe1585d77 --- /dev/null +++ b/profiles/preview/preview/sql/mgmt/sql/models.go @@ -0,0 +1,371 @@ +// +build go1.9 + +// Copyright 2018 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package sql + +import original "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-10-01-preview/sql" + +type CapabilitiesClient = original.CapabilitiesClient + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type BaseClient = original.BaseClient +type DatabaseOperationsClient = original.DatabaseOperationsClient +type DatabasesClient = original.DatabasesClient +type ElasticPoolOperationsClient = original.ElasticPoolOperationsClient +type ElasticPoolsClient = original.ElasticPoolsClient +type InstanceFailoverGroupsClient = original.InstanceFailoverGroupsClient +type CapabilityGroup = original.CapabilityGroup + +const ( + SupportedEditions CapabilityGroup = original.SupportedEditions + SupportedElasticPoolEditions CapabilityGroup = original.SupportedElasticPoolEditions + SupportedManagedInstanceVersions CapabilityGroup = original.SupportedManagedInstanceVersions +) + +type CapabilityStatus = original.CapabilityStatus + +const ( + Available CapabilityStatus = original.Available + Default CapabilityStatus = original.Default + Disabled CapabilityStatus = original.Disabled + Visible CapabilityStatus = original.Visible +) + +type CatalogCollationType = original.CatalogCollationType + +const ( + DATABASEDEFAULT CatalogCollationType = original.DATABASEDEFAULT + SQLLatin1GeneralCP1CIAS CatalogCollationType = original.SQLLatin1GeneralCP1CIAS +) + +type CreateMode = original.CreateMode + +const ( + CreateModeCopy CreateMode = original.CreateModeCopy + CreateModeDefault CreateMode = original.CreateModeDefault + CreateModeOnlineSecondary CreateMode = original.CreateModeOnlineSecondary + CreateModePointInTimeRestore CreateMode = original.CreateModePointInTimeRestore + CreateModeRecovery CreateMode = original.CreateModeRecovery + CreateModeRestore CreateMode = original.CreateModeRestore + CreateModeRestoreExternalBackup CreateMode = original.CreateModeRestoreExternalBackup + CreateModeRestoreExternalBackupSecondary CreateMode = original.CreateModeRestoreExternalBackupSecondary + CreateModeRestoreLongTermRetentionBackup CreateMode = original.CreateModeRestoreLongTermRetentionBackup + CreateModeSecondary CreateMode = original.CreateModeSecondary +) + +type DatabaseLicenseType = original.DatabaseLicenseType + +const ( + BasePrice DatabaseLicenseType = original.BasePrice + LicenseIncluded DatabaseLicenseType = original.LicenseIncluded +) + +type DatabaseReadScale = original.DatabaseReadScale + +const ( + DatabaseReadScaleDisabled DatabaseReadScale = original.DatabaseReadScaleDisabled + DatabaseReadScaleEnabled DatabaseReadScale = original.DatabaseReadScaleEnabled +) + +type DatabaseStatus = original.DatabaseStatus + +const ( + AutoClosed DatabaseStatus = original.AutoClosed + Copying DatabaseStatus = original.Copying + Creating DatabaseStatus = original.Creating + EmergencyMode DatabaseStatus = original.EmergencyMode + Inaccessible DatabaseStatus = original.Inaccessible + Offline DatabaseStatus = original.Offline + OfflineSecondary DatabaseStatus = original.OfflineSecondary + Online DatabaseStatus = original.Online + Paused DatabaseStatus = original.Paused + Pausing DatabaseStatus = original.Pausing + Recovering DatabaseStatus = original.Recovering + RecoveryPending DatabaseStatus = original.RecoveryPending + Restoring DatabaseStatus = original.Restoring + Resuming DatabaseStatus = original.Resuming + Scaling DatabaseStatus = original.Scaling + Shutdown DatabaseStatus = original.Shutdown + Standby DatabaseStatus = original.Standby + Suspect DatabaseStatus = original.Suspect +) + +type ElasticPoolLicenseType = original.ElasticPoolLicenseType + +const ( + ElasticPoolLicenseTypeBasePrice ElasticPoolLicenseType = original.ElasticPoolLicenseTypeBasePrice + ElasticPoolLicenseTypeLicenseIncluded ElasticPoolLicenseType = original.ElasticPoolLicenseTypeLicenseIncluded +) + +type ElasticPoolState = original.ElasticPoolState + +const ( + ElasticPoolStateCreating ElasticPoolState = original.ElasticPoolStateCreating + ElasticPoolStateDisabled ElasticPoolState = original.ElasticPoolStateDisabled + ElasticPoolStateReady ElasticPoolState = original.ElasticPoolStateReady +) + +type InstanceFailoverGroupReplicationRole = original.InstanceFailoverGroupReplicationRole + +const ( + Primary InstanceFailoverGroupReplicationRole = original.Primary + Secondary InstanceFailoverGroupReplicationRole = original.Secondary +) + +type LogSizeUnit = original.LogSizeUnit + +const ( + Gigabytes LogSizeUnit = original.Gigabytes + Megabytes LogSizeUnit = original.Megabytes + Percent LogSizeUnit = original.Percent + Petabytes LogSizeUnit = original.Petabytes + Terabytes LogSizeUnit = original.Terabytes +) + +type ManagementOperationState = original.ManagementOperationState + +const ( + CancelInProgress ManagementOperationState = original.CancelInProgress + Cancelled ManagementOperationState = original.Cancelled + Failed ManagementOperationState = original.Failed + InProgress ManagementOperationState = original.InProgress + Pending ManagementOperationState = original.Pending + Succeeded ManagementOperationState = original.Succeeded +) + +type MaxSizeUnit = original.MaxSizeUnit + +const ( + MaxSizeUnitGigabytes MaxSizeUnit = original.MaxSizeUnitGigabytes + MaxSizeUnitMegabytes MaxSizeUnit = original.MaxSizeUnitMegabytes + MaxSizeUnitPetabytes MaxSizeUnit = original.MaxSizeUnitPetabytes + MaxSizeUnitTerabytes MaxSizeUnit = original.MaxSizeUnitTerabytes +) + +type PerformanceLevelUnit = original.PerformanceLevelUnit + +const ( + DTU PerformanceLevelUnit = original.DTU + VCores PerformanceLevelUnit = original.VCores +) + +type ReadOnlyEndpointFailoverPolicy = original.ReadOnlyEndpointFailoverPolicy + +const ( + ReadOnlyEndpointFailoverPolicyDisabled ReadOnlyEndpointFailoverPolicy = original.ReadOnlyEndpointFailoverPolicyDisabled + ReadOnlyEndpointFailoverPolicyEnabled ReadOnlyEndpointFailoverPolicy = original.ReadOnlyEndpointFailoverPolicyEnabled +) + +type ReadWriteEndpointFailoverPolicy = original.ReadWriteEndpointFailoverPolicy + +const ( + Automatic ReadWriteEndpointFailoverPolicy = original.Automatic + Manual ReadWriteEndpointFailoverPolicy = original.Manual +) + +type SampleName = original.SampleName + +const ( + AdventureWorksLT SampleName = original.AdventureWorksLT + WideWorldImportersFull SampleName = original.WideWorldImportersFull + WideWorldImportersStd SampleName = original.WideWorldImportersStd +) + +type Database = original.Database +type DatabaseListResult = original.DatabaseListResult +type DatabaseListResultIterator = original.DatabaseListResultIterator +type DatabaseListResultPage = original.DatabaseListResultPage +type DatabaseOperation = original.DatabaseOperation +type DatabaseOperationListResult = original.DatabaseOperationListResult +type DatabaseOperationListResultIterator = original.DatabaseOperationListResultIterator +type DatabaseOperationListResultPage = original.DatabaseOperationListResultPage +type DatabaseOperationProperties = original.DatabaseOperationProperties +type DatabaseProperties = original.DatabaseProperties +type DatabasesCreateOrUpdateFuture = original.DatabasesCreateOrUpdateFuture +type DatabasesDeleteFuture = original.DatabasesDeleteFuture +type DatabasesPauseFuture = original.DatabasesPauseFuture +type DatabasesResumeFuture = original.DatabasesResumeFuture +type DatabasesUpdateFuture = original.DatabasesUpdateFuture +type DatabasesUpgradeDataWarehouseFuture = original.DatabasesUpgradeDataWarehouseFuture +type DatabaseUpdate = original.DatabaseUpdate +type EditionCapability = original.EditionCapability +type ElasticPool = original.ElasticPool +type ElasticPoolEditionCapability = original.ElasticPoolEditionCapability +type ElasticPoolListResult = original.ElasticPoolListResult +type ElasticPoolListResultIterator = original.ElasticPoolListResultIterator +type ElasticPoolListResultPage = original.ElasticPoolListResultPage +type ElasticPoolOperation = original.ElasticPoolOperation +type ElasticPoolOperationListResult = original.ElasticPoolOperationListResult +type ElasticPoolOperationListResultIterator = original.ElasticPoolOperationListResultIterator +type ElasticPoolOperationListResultPage = original.ElasticPoolOperationListResultPage +type ElasticPoolOperationProperties = original.ElasticPoolOperationProperties +type ElasticPoolPerDatabaseMaxPerformanceLevelCapability = original.ElasticPoolPerDatabaseMaxPerformanceLevelCapability +type ElasticPoolPerDatabaseMinPerformanceLevelCapability = original.ElasticPoolPerDatabaseMinPerformanceLevelCapability +type ElasticPoolPerDatabaseSettings = original.ElasticPoolPerDatabaseSettings +type ElasticPoolPerformanceLevelCapability = original.ElasticPoolPerformanceLevelCapability +type ElasticPoolProperties = original.ElasticPoolProperties +type ElasticPoolsCreateOrUpdateFuture = original.ElasticPoolsCreateOrUpdateFuture +type ElasticPoolsDeleteFuture = original.ElasticPoolsDeleteFuture +type ElasticPoolsUpdateFuture = original.ElasticPoolsUpdateFuture +type ElasticPoolUpdate = original.ElasticPoolUpdate +type ElasticPoolUpdateProperties = original.ElasticPoolUpdateProperties +type InstanceFailoverGroup = original.InstanceFailoverGroup +type InstanceFailoverGroupListResult = original.InstanceFailoverGroupListResult +type InstanceFailoverGroupListResultIterator = original.InstanceFailoverGroupListResultIterator +type InstanceFailoverGroupListResultPage = original.InstanceFailoverGroupListResultPage +type InstanceFailoverGroupProperties = original.InstanceFailoverGroupProperties +type InstanceFailoverGroupReadOnlyEndpoint = original.InstanceFailoverGroupReadOnlyEndpoint +type InstanceFailoverGroupReadWriteEndpoint = original.InstanceFailoverGroupReadWriteEndpoint +type InstanceFailoverGroupsCreateOrUpdateFuture = original.InstanceFailoverGroupsCreateOrUpdateFuture +type InstanceFailoverGroupsDeleteFuture = original.InstanceFailoverGroupsDeleteFuture +type InstanceFailoverGroupsFailoverFuture = original.InstanceFailoverGroupsFailoverFuture +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture = original.InstanceFailoverGroupsForceFailoverAllowDataLossFuture +type LicenseTypeCapability = original.LicenseTypeCapability +type LocationCapabilities = original.LocationCapabilities +type LogSizeCapability = original.LogSizeCapability +type ManagedInstanceEditionCapability = original.ManagedInstanceEditionCapability +type ManagedInstanceFamilyCapability = original.ManagedInstanceFamilyCapability +type ManagedInstancePairInfo = original.ManagedInstancePairInfo +type ManagedInstanceVcoresCapability = original.ManagedInstanceVcoresCapability +type ManagedInstanceVersionCapability = original.ManagedInstanceVersionCapability +type MaxSizeCapability = original.MaxSizeCapability +type MaxSizeRangeCapability = original.MaxSizeRangeCapability +type PartnerRegionInfo = original.PartnerRegionInfo +type PerformanceLevelCapability = original.PerformanceLevelCapability +type ProxyResource = original.ProxyResource +type Resource = original.Resource +type ResourceMoveDefinition = original.ResourceMoveDefinition +type ServerVersionCapability = original.ServerVersionCapability +type ServiceObjectiveCapability = original.ServiceObjectiveCapability +type ShortTermRetentionPoliciesCreateOrUpdateFuture = original.ShortTermRetentionPoliciesCreateOrUpdateFuture +type ShortTermRetentionPoliciesUpdateFuture = original.ShortTermRetentionPoliciesUpdateFuture +type ShortTermRetentionPolicy = original.ShortTermRetentionPolicy +type ShortTermRetentionPolicyProperties = original.ShortTermRetentionPolicyProperties +type Sku = original.Sku +type TrackedResource = original.TrackedResource +type ShortTermRetentionPoliciesClient = original.ShortTermRetentionPoliciesClient + +func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { + return original.NewCapabilitiesClient(subscriptionID) +} +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return original.NewCapabilitiesClientWithBaseURI(baseURI, subscriptionID) +} +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func NewDatabaseOperationsClient(subscriptionID string) DatabaseOperationsClient { + return original.NewDatabaseOperationsClient(subscriptionID) +} +func NewDatabaseOperationsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseOperationsClient { + return original.NewDatabaseOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return original.NewDatabasesClient(subscriptionID) +} +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return original.NewDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewElasticPoolOperationsClient(subscriptionID string) ElasticPoolOperationsClient { + return original.NewElasticPoolOperationsClient(subscriptionID) +} +func NewElasticPoolOperationsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolOperationsClient { + return original.NewElasticPoolOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewElasticPoolsClient(subscriptionID string) ElasticPoolsClient { + return original.NewElasticPoolsClient(subscriptionID) +} +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return original.NewElasticPoolsClientWithBaseURI(baseURI, subscriptionID) +} +func NewInstanceFailoverGroupsClient(subscriptionID string) InstanceFailoverGroupsClient { + return original.NewInstanceFailoverGroupsClient(subscriptionID) +} +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return original.NewInstanceFailoverGroupsClientWithBaseURI(baseURI, subscriptionID) +} +func PossibleCapabilityGroupValues() []CapabilityGroup { + return original.PossibleCapabilityGroupValues() +} +func PossibleCapabilityStatusValues() []CapabilityStatus { + return original.PossibleCapabilityStatusValues() +} +func PossibleCatalogCollationTypeValues() []CatalogCollationType { + return original.PossibleCatalogCollationTypeValues() +} +func PossibleCreateModeValues() []CreateMode { + return original.PossibleCreateModeValues() +} +func PossibleDatabaseLicenseTypeValues() []DatabaseLicenseType { + return original.PossibleDatabaseLicenseTypeValues() +} +func PossibleDatabaseReadScaleValues() []DatabaseReadScale { + return original.PossibleDatabaseReadScaleValues() +} +func PossibleDatabaseStatusValues() []DatabaseStatus { + return original.PossibleDatabaseStatusValues() +} +func PossibleElasticPoolLicenseTypeValues() []ElasticPoolLicenseType { + return original.PossibleElasticPoolLicenseTypeValues() +} +func PossibleElasticPoolStateValues() []ElasticPoolState { + return original.PossibleElasticPoolStateValues() +} +func PossibleInstanceFailoverGroupReplicationRoleValues() []InstanceFailoverGroupReplicationRole { + return original.PossibleInstanceFailoverGroupReplicationRoleValues() +} +func PossibleLogSizeUnitValues() []LogSizeUnit { + return original.PossibleLogSizeUnitValues() +} +func PossibleManagementOperationStateValues() []ManagementOperationState { + return original.PossibleManagementOperationStateValues() +} +func PossibleMaxSizeUnitValues() []MaxSizeUnit { + return original.PossibleMaxSizeUnitValues() +} +func PossiblePerformanceLevelUnitValues() []PerformanceLevelUnit { + return original.PossiblePerformanceLevelUnitValues() +} +func PossibleReadOnlyEndpointFailoverPolicyValues() []ReadOnlyEndpointFailoverPolicy { + return original.PossibleReadOnlyEndpointFailoverPolicyValues() +} +func PossibleReadWriteEndpointFailoverPolicyValues() []ReadWriteEndpointFailoverPolicy { + return original.PossibleReadWriteEndpointFailoverPolicyValues() +} +func PossibleSampleNameValues() []SampleName { + return original.PossibleSampleNameValues() +} +func NewShortTermRetentionPoliciesClient(subscriptionID string) ShortTermRetentionPoliciesClient { + return original.NewShortTermRetentionPoliciesClient(subscriptionID) +} +func NewShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ShortTermRetentionPoliciesClient { + return original.NewShortTermRetentionPoliciesClientWithBaseURI(baseURI, subscriptionID) +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/profiles/preview/sql/mgmt/sql/models.go b/profiles/preview/sql/mgmt/sql/models.go index e2a618ec747b..710f688bfa53 100644 --- a/profiles/preview/sql/mgmt/sql/models.go +++ b/profiles/preview/sql/mgmt/sql/models.go @@ -28,6 +28,14 @@ const ( type BaseClient = original.BaseClient type DatabaseOperationsClient = original.DatabaseOperationsClient type ElasticPoolOperationsClient = original.ElasticPoolOperationsClient +type InstanceFailoverGroupsClient = original.InstanceFailoverGroupsClient +type InstanceFailoverGroupReplicationRole = original.InstanceFailoverGroupReplicationRole + +const ( + Primary InstanceFailoverGroupReplicationRole = original.Primary + Secondary InstanceFailoverGroupReplicationRole = original.Secondary +) + type ManagementOperationState = original.ManagementOperationState const ( @@ -39,6 +47,20 @@ const ( Succeeded ManagementOperationState = original.Succeeded ) +type ReadOnlyEndpointFailoverPolicy = original.ReadOnlyEndpointFailoverPolicy + +const ( + Disabled ReadOnlyEndpointFailoverPolicy = original.Disabled + Enabled ReadOnlyEndpointFailoverPolicy = original.Enabled +) + +type ReadWriteEndpointFailoverPolicy = original.ReadWriteEndpointFailoverPolicy + +const ( + Automatic ReadWriteEndpointFailoverPolicy = original.Automatic + Manual ReadWriteEndpointFailoverPolicy = original.Manual +) + type DatabaseOperation = original.DatabaseOperation type DatabaseOperationListResult = original.DatabaseOperationListResult type DatabaseOperationListResultIterator = original.DatabaseOperationListResultIterator @@ -49,6 +71,19 @@ type ElasticPoolOperationListResult = original.ElasticPoolOperationListResult type ElasticPoolOperationListResultIterator = original.ElasticPoolOperationListResultIterator type ElasticPoolOperationListResultPage = original.ElasticPoolOperationListResultPage type ElasticPoolOperationProperties = original.ElasticPoolOperationProperties +type InstanceFailoverGroup = original.InstanceFailoverGroup +type InstanceFailoverGroupListResult = original.InstanceFailoverGroupListResult +type InstanceFailoverGroupListResultIterator = original.InstanceFailoverGroupListResultIterator +type InstanceFailoverGroupListResultPage = original.InstanceFailoverGroupListResultPage +type InstanceFailoverGroupProperties = original.InstanceFailoverGroupProperties +type InstanceFailoverGroupReadOnlyEndpoint = original.InstanceFailoverGroupReadOnlyEndpoint +type InstanceFailoverGroupReadWriteEndpoint = original.InstanceFailoverGroupReadWriteEndpoint +type InstanceFailoverGroupsCreateOrUpdateFuture = original.InstanceFailoverGroupsCreateOrUpdateFuture +type InstanceFailoverGroupsDeleteFuture = original.InstanceFailoverGroupsDeleteFuture +type InstanceFailoverGroupsFailoverFuture = original.InstanceFailoverGroupsFailoverFuture +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture = original.InstanceFailoverGroupsForceFailoverAllowDataLossFuture +type ManagedInstancePairInfo = original.ManagedInstancePairInfo +type PartnerRegionInfo = original.PartnerRegionInfo type ProxyResource = original.ProxyResource type Resource = original.Resource @@ -70,9 +105,24 @@ func NewElasticPoolOperationsClient(subscriptionID string) ElasticPoolOperations func NewElasticPoolOperationsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolOperationsClient { return original.NewElasticPoolOperationsClientWithBaseURI(baseURI, subscriptionID) } +func NewInstanceFailoverGroupsClient(subscriptionID string) InstanceFailoverGroupsClient { + return original.NewInstanceFailoverGroupsClient(subscriptionID) +} +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return original.NewInstanceFailoverGroupsClientWithBaseURI(baseURI, subscriptionID) +} +func PossibleInstanceFailoverGroupReplicationRoleValues() []InstanceFailoverGroupReplicationRole { + return original.PossibleInstanceFailoverGroupReplicationRoleValues() +} func PossibleManagementOperationStateValues() []ManagementOperationState { return original.PossibleManagementOperationStateValues() } +func PossibleReadOnlyEndpointFailoverPolicyValues() []ReadOnlyEndpointFailoverPolicy { + return original.PossibleReadOnlyEndpointFailoverPolicyValues() +} +func PossibleReadWriteEndpointFailoverPolicyValues() []ReadWriteEndpointFailoverPolicy { + return original.PossibleReadWriteEndpointFailoverPolicyValues() +} func UserAgent() string { return original.UserAgent() + " profiles/preview" } diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/backuplongtermretentionpolicies.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/backuplongtermretentionpolicies.go new file mode 100644 index 000000000000..0d976685371b --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/backuplongtermretentionpolicies.go @@ -0,0 +1,264 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupLongTermRetentionPoliciesClient 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 BackupLongTermRetentionPoliciesClient struct { + BaseClient +} + +// NewBackupLongTermRetentionPoliciesClient creates an instance of the BackupLongTermRetentionPoliciesClient client. +func NewBackupLongTermRetentionPoliciesClient(subscriptionID string) BackupLongTermRetentionPoliciesClient { + return NewBackupLongTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupLongTermRetentionPoliciesClientWithBaseURI creates an instance of the BackupLongTermRetentionPoliciesClient +// client. +func NewBackupLongTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupLongTermRetentionPoliciesClient { + return BackupLongTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database backup long term retention policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database parameters is the required parameters to update a backup long term retention policy +func (client BackupLongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupLongTermRetentionPolicy) (result BackupLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionPolicyProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionPolicyProperties.RecoveryServicesBackupPolicyResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.BackupLongTermRetentionPoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupLongTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupLongTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionPolicyName": 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 = "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}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}", 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 BackupLongTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future BackupLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns a database backup long term retention policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client BackupLongTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupLongTermRetentionPolicy, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "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.BackupLongTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupLongTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionPolicyName": 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 = "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}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}", 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 BackupLongTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result BackupLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a database backup long term retention policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client BackupLongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupLongTermRetentionPolicyListResult, err error) { + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "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.BackupLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client BackupLongTermRetentionPoliciesClient) 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}/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 BackupLongTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result BackupLongTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/backuplongtermretentionvaults.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/backuplongtermretentionvaults.go new file mode 100644 index 000000000000..1a67bbc0210c --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/backuplongtermretentionvaults.go @@ -0,0 +1,259 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupLongTermRetentionVaultsClient 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 BackupLongTermRetentionVaultsClient struct { + BaseClient +} + +// NewBackupLongTermRetentionVaultsClient creates an instance of the BackupLongTermRetentionVaultsClient client. +func NewBackupLongTermRetentionVaultsClient(subscriptionID string) BackupLongTermRetentionVaultsClient { + return NewBackupLongTermRetentionVaultsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupLongTermRetentionVaultsClientWithBaseURI creates an instance of the BackupLongTermRetentionVaultsClient +// client. +func NewBackupLongTermRetentionVaultsClientWithBaseURI(baseURI string, subscriptionID string) BackupLongTermRetentionVaultsClient { + return BackupLongTermRetentionVaultsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a server backup long term retention vault +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the required +// parameters to update a backup long term retention vault +func (client BackupLongTermRetentionVaultsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters BackupLongTermRetentionVault) (result BackupLongTermRetentionVaultsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionVaultProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionVaultProperties.RecoveryServicesVaultResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.BackupLongTermRetentionVaultsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupLongTermRetentionVaultsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters BackupLongTermRetentionVault) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionVaultName": autorest.Encode("path", "RegisteredVault"), + "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}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}", 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 BackupLongTermRetentionVaultsClient) CreateOrUpdateSender(req *http.Request) (future BackupLongTermRetentionVaultsCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionVaultsClient) CreateOrUpdateResponder(resp *http.Response) (result BackupLongTermRetentionVault, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server backup long term retention vault +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client BackupLongTermRetentionVaultsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result BackupLongTermRetentionVault, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "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.BackupLongTermRetentionVaultsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupLongTermRetentionVaultsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionVaultName": autorest.Encode("path", "RegisteredVault"), + "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}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}", 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 BackupLongTermRetentionVaultsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionVaultsClient) GetResponder(resp *http.Response) (result BackupLongTermRetentionVault, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets server backup long term retention vaults in a server +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client BackupLongTermRetentionVaultsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result BackupLongTermRetentionVaultListResult, err error) { + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "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.BackupLongTermRetentionVaultsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client BackupLongTermRetentionVaultsClient) 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}/backupLongTermRetentionVaults", 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 BackupLongTermRetentionVaultsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionVaultsClient) ListByServerResponder(resp *http.Response) (result BackupLongTermRetentionVaultListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..cc587af8e212 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/capabilities.go @@ -0,0 +1,107 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the subscription capabilities available for the specified location. +// +// locationName is the location name whose capabilities are retrieved. +func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationName string) (result LocationCapabilities, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..40ec57b36bab --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/client.go @@ -0,0 +1,52 @@ +// 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 and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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. +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..8770fc0e82a9 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseblobauditingpolicies.go @@ -0,0 +1,186 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return DatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's blob auditing policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the blob auditing policy will be defined. parameters is the database blob auditing +// policy. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (result DatabaseBlobAuditingPolicy, err error) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's blob auditing policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the blob audit policy is defined. +func (client DatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..164f6b989b2a --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databases.go @@ -0,0 +1,1206 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to import into parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be operated on (updated or created). parameters is 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) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be deleted. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Export exports a database to a bacpac. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be exported. parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be retrieved. expand is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool to be retrieved. databaseName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByRecommendedElasticPool gets a database inside of a recommented elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. recommendedElasticPoolName +// is the name of the elastic pool to be retrieved. databaseName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Import imports a bacpac into a new database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRecommendedElasticPool returns a list of databases inside a recommented elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. recommendedElasticPoolName +// is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. expand is a comma separated +// list of child objects to expand in the response. Possible properties: serviceTierAdvisors, +// transparentDataEncryption. filter is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions returns database metric definitions. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabasesClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result MetricDefinitionListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns database metrics. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. filter is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Pause pauses a data warehouse. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the data warehouse to pause. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a data warehouse. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the data warehouse to resume. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be updated. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..fdb9dee3f2c9 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databasethreatdetectionpolicies.go @@ -0,0 +1,186 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDatabaseThreatDetectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseThreatDetectionPoliciesClient { + return DatabaseThreatDetectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's threat detection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which database Threat Detection policy is defined. parameters is the database Threat Detection +// policy. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (result DatabaseSecurityAlertPolicy, err error) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's threat detection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) GetResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..2d531bfa202a --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/databaseusages.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDatabaseUsagesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseUsagesClient { + return DatabaseUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase returns database usages. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabaseUsagesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..d462b4be078f --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingpolicies.go @@ -0,0 +1,184 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDataMaskingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingPoliciesClient { + return DataMaskingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is 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) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database data masking policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DataMaskingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) GetResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..5eb74d5df714 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/datamaskingrules.go @@ -0,0 +1,197 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewDataMaskingRulesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingRulesClient { + return DataMaskingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. dataMaskingRuleName is the name of the data masking rule. parameters is 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 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database data masking rules. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DataMaskingRulesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingRuleListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..207c81fcc0b2 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpoolactivities.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewElasticPoolActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolActivitiesClient { + return ElasticPoolActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns elastic pool activities. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..ce30d93c6839 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpooldatabaseactivities.go @@ -0,0 +1,112 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewElasticPoolDatabaseActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return ElasticPoolDatabaseActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns activity on databases inside of an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolDatabaseActivityListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..c56f6a3e5738 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/elasticpools.go @@ -0,0 +1,532 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new elastic pool or updates an existing elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool to be operated on (updated or created). parameters is 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) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of elastic pools in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ElasticPoolListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions returns elastic pool metric definitions. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client ElasticPoolsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result MetricDefinitionListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns elastic pool metrics. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. filter is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool to be updated. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..6f96e37ce1fc --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/encryptionprotectors.go @@ -0,0 +1,278 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) EncryptionProtectorsClient { + return EncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// encryption protector resource state. +func (client EncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (result EncryptionProtectorsCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server encryption protector. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client EncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtector, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) GetResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server encryption protectors +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client EncryptionProtectorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) ListByServerResponder(resp *http.Response) (result EncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client EncryptionProtectorsClient) listByServerNextResults(lastResults EncryptionProtectorListResult) (result EncryptionProtectorListResult, err error) { + req, err := lastResults.encryptionProtectorListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} 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..06b0ae818b14 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/failovergroups.go @@ -0,0 +1,576 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) FailoverGroupsClient { + return FailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. parameters is the failover group parameters. +func (client FailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (result FailoverGroupsCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary server to this server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsFailoverFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroup, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) GetResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the failover groups in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. +func (client FailoverGroupsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ListByServerResponder(resp *http.Response) (result FailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FailoverGroupsClient) listByServerNextResults(lastResults FailoverGroupListResult) (result FailoverGroupListResult, err error) { + req, err := lastResults.failoverGroupListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. parameters is the failover group parameters. +func (client FailoverGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (result FailoverGroupsUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) UpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..39889599b694 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/firewallrules.go @@ -0,0 +1,327 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. firewallRuleName is the name +// of the firewall rule. parameters is 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 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. firewallRuleName is the name +// of the firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. firewallRuleName is the name +// of the firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of firewall rules. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..fc98307265c5 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/geobackuppolicies.go @@ -0,0 +1,260 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewGeoBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) GeoBackupPoliciesClient { + return GeoBackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database geo backup policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the 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 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a geo backup policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client GeoBackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) GetResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a list of geo backup policies. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client GeoBackupPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicyListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..816c0028db69 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/managedinstances.go @@ -0,0 +1,513 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstance, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..8e20a0065a76 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/models.go @@ -0,0 +1,9979 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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/satori/go.uuid" + "net/http" +) + +// 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} +} + +// BackupLongTermRetentionPolicyState enumerates the values for backup long term retention policy state. +type BackupLongTermRetentionPolicyState string + +const ( + // Disabled ... + Disabled BackupLongTermRetentionPolicyState = "Disabled" + // Enabled ... + Enabled BackupLongTermRetentionPolicyState = "Enabled" +) + +// PossibleBackupLongTermRetentionPolicyStateValues returns an array of possible values for the BackupLongTermRetentionPolicyState const type. +func PossibleBackupLongTermRetentionPolicyStateValues() []BackupLongTermRetentionPolicyState { + return []BackupLongTermRetentionPolicyState{Disabled, Enabled} +} + +// 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} +} + +// 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" + // DataWarehouse ... + DataWarehouse DatabaseEdition = "DataWarehouse" + // Free ... + Free DatabaseEdition = "Free" + // 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, DataWarehouse, Free, 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" + // 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, 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 ( + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{SystemAssigned} +} + +// 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 ( + // Average ... + Average PrimaryAggregationType = "Average" + // Count ... + Count PrimaryAggregationType = "Count" + // Maximum ... + Maximum PrimaryAggregationType = "Maximum" + // Minimum ... + Minimum PrimaryAggregationType = "Minimum" + // None ... + None PrimaryAggregationType = "None" + // Total ... + Total 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} +} + +// 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 ( + // 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 ( + // 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} +} + +// BackupLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type BackupLongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future BackupLongTermRetentionPoliciesCreateOrUpdateFuture) Result(client BackupLongTermRetentionPoliciesClient) (bltrp BackupLongTermRetentionPolicy, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return bltrp, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + bltrp, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + bltrp, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// BackupLongTermRetentionPolicy a backup long term retention policy +type BackupLongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // BackupLongTermRetentionPolicyProperties - The properties of the backup long term retention policy + *BackupLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = bltrp.Location + } + if bltrp.BackupLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = bltrp.BackupLongTermRetentionPolicyProperties + } + if bltrp.ID != nil { + objectMap["id"] = bltrp.ID + } + if bltrp.Name != nil { + objectMap["name"] = bltrp.Name + } + if bltrp.Type != nil { + objectMap["type"] = bltrp.Type + } + 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 "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + bltrp.Location = &location + } + case "properties": + if v != nil { + var backupLongTermRetentionPolicyProperties BackupLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &backupLongTermRetentionPolicyProperties) + if err != nil { + return err + } + bltrp.BackupLongTermRetentionPolicyProperties = &backupLongTermRetentionPolicyProperties + } + 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 +} + +// BackupLongTermRetentionPolicyListResult represents the response to a list long-term retention policies request. +type BackupLongTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - The list of long-term retention policies in the database. + Value *[]BackupLongTermRetentionPolicy `json:"value,omitempty"` +} + +// BackupLongTermRetentionPolicyProperties the properties of a backup long term retention policy +type BackupLongTermRetentionPolicyProperties struct { + // State - The status of the backup long term retention policy. Possible values include: 'Disabled', 'Enabled' + State BackupLongTermRetentionPolicyState `json:"state,omitempty"` + // RecoveryServicesBackupPolicyResourceID - The azure recovery services backup protection policy resource id + RecoveryServicesBackupPolicyResourceID *string `json:"recoveryServicesBackupPolicyResourceId,omitempty"` +} + +// BackupLongTermRetentionVault a backup long term retention vault +type BackupLongTermRetentionVault struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // BackupLongTermRetentionVaultProperties - The properties of the backup long term retention vault + *BackupLongTermRetentionVaultProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupLongTermRetentionVault. +func (bltrv BackupLongTermRetentionVault) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bltrv.Location != nil { + objectMap["location"] = bltrv.Location + } + if bltrv.BackupLongTermRetentionVaultProperties != nil { + objectMap["properties"] = bltrv.BackupLongTermRetentionVaultProperties + } + if bltrv.ID != nil { + objectMap["id"] = bltrv.ID + } + if bltrv.Name != nil { + objectMap["name"] = bltrv.Name + } + if bltrv.Type != nil { + objectMap["type"] = bltrv.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupLongTermRetentionVault struct. +func (bltrv *BackupLongTermRetentionVault) 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 + } + bltrv.Location = &location + } + case "properties": + if v != nil { + var backupLongTermRetentionVaultProperties BackupLongTermRetentionVaultProperties + err = json.Unmarshal(*v, &backupLongTermRetentionVaultProperties) + if err != nil { + return err + } + bltrv.BackupLongTermRetentionVaultProperties = &backupLongTermRetentionVaultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bltrv.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bltrv.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bltrv.Type = &typeVar + } + } + } + + return nil +} + +// BackupLongTermRetentionVaultListResult represents the response to a list vaults request. +type BackupLongTermRetentionVaultListResult struct { + autorest.Response `json:"-"` + // Value - The list of vaults in the server. + Value *[]BackupLongTermRetentionVault `json:"value,omitempty"` +} + +// BackupLongTermRetentionVaultProperties the properties of a backup long term retention vault. +type BackupLongTermRetentionVaultProperties struct { + // RecoveryServicesVaultResourceID - The azure recovery services vault resource id + RecoveryServicesVaultResourceID *string `json:"recoveryServicesVaultResourceId,omitempty"` +} + +// BackupLongTermRetentionVaultsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type BackupLongTermRetentionVaultsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future BackupLongTermRetentionVaultsCreateOrUpdateFuture) Result(client BackupLongTermRetentionVaultsClient) (bltrv BackupLongTermRetentionVault, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return bltrv, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + bltrv, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + bltrv, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - True if the name is available, otherwise false. + Available *bool `json:"available,omitempty"` + // Message - A message explaining why the name is unavailable. Will be null if the name is available. + Message *string `json:"message,omitempty"` + // Name - The name whose availability was checked. + Name *string `json:"name,omitempty"` + // Reason - 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"` +} + +// Database represents a database. +type Database struct { + autorest.Response `json:"-"` + // Kind - 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"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = d.Kind + } + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Type != nil { + objectMap["type"] = d.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + 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 - Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseBlobAuditingPolicyProperties - Resource properties. + *DatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = dbap.Kind + } + if dbap.DatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = dbap.DatabaseBlobAuditingPolicyProperties + } + if dbap.ID != nil { + objectMap["id"] = dbap.ID + } + if dbap.Name != nil { + objectMap["name"] = dbap.Name + } + if dbap.Type != nil { + objectMap["type"] = dbap.Type + } + 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 +} + +// DatabaseBlobAuditingPolicyProperties properties of a database blob auditing policy. +type DatabaseBlobAuditingPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint and storageAccountAccessKey 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 is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. If state is Enabled, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions and Actions-Groups to audit. + 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"` +} + +// 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 - The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // ContainmentState - The containment state of the database. + ContainmentState *int64 `json:"containmentState,omitempty"` + // CurrentServiceObjectiveID - 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 - The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // EarliestRestoreDate - 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. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." or use the Azure CLI command `az sql db list-editions -l westus --query [].name`. Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2' + 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. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." or use the Azure CLI command `az sql db list-editions --location --query [].supportedServiceLevelObjectives[].name` . + 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. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." or use the Azure CLI command `az sql db list-editions --location --query [].supportedServiceLevelObjectives[].name`. 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 - 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 - 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 - The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // ServiceTierAdvisors - The list of service tier advisors for this database. Expanded property + ServiceTierAdvisors *[]ServiceTierAdvisor `json:"serviceTierAdvisors,omitempty"` + // TransparentDataEncryption - The transparent data encryption info for this database. + TransparentDataEncryption *[]TransparentDataEncryption `json:"transparentDataEncryption,omitempty"` + // RecommendedIndex - The recommended indices for this database. + RecommendedIndex *[]RecommendedIndex `json:"recommendedIndex,omitempty"` + // FailoverGroupID - 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"` +} + +// DatabasesCreateImportOperationFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateImportOperationFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesCreateImportOperationFuture) Result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateImportOperationFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ier, err = client.CreateImportOperationResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure sending request") + return + } + ier, err = client.CreateImportOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseSecurityAlertPolicyProperties - Properties of the security alert policy. + *DatabaseSecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = dsap.Kind + } + if dsap.DatabaseSecurityAlertPolicyProperties != nil { + objectMap["properties"] = dsap.DatabaseSecurityAlertPolicyProperties + } + if dsap.ID != nil { + objectMap["id"] = dsap.ID + } + if dsap.Name != nil { + objectMap["name"] = dsap.Name + } + if dsap.Type != nil { + objectMap["type"] = dsap.Type + } + 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; Usage_Anomaly. + 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesExportFuture) Result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ier, err = client.ExportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure sending request") + return + } + ier, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesImportFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesImportFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesImportFuture) Result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ier, err = client.ImportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure sending request") + return + } + ier, err = client.ImportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesPauseFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesPauseFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.PauseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesResumeFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesResumeFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.ResumeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if du.ID != nil { + objectMap["id"] = du.ID + } + if du.Name != nil { + objectMap["name"] = du.Name + } + if du.Type != nil { + objectMap["type"] = du.Type + } + 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 - The name of the usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - The usage metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - The current value of the usage metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - The current limit of the usage metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - The units of the usage metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - The next reset time for the usage metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// 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 - The location of the data masking policy. + Location *string `json:"location,omitempty"` + // Kind - The kind of data masking policy. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if dmp.Location != nil { + objectMap["location"] = dmp.Location + } + if dmp.Kind != nil { + objectMap["kind"] = dmp.Kind + } + if dmp.ID != nil { + objectMap["id"] = dmp.ID + } + if dmp.Name != nil { + objectMap["name"] = dmp.Name + } + if dmp.Type != nil { + objectMap["type"] = dmp.Type + } + 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 - The list of the application principals. This is a legacy parameter and is no longer used. + ApplicationPrincipals *string `json:"applicationPrincipals,omitempty"` + // MaskingLevel - The masking level. This is a legacy parameter and is no longer used. + MaskingLevel *string `json:"maskingLevel,omitempty"` +} + +// DataMaskingRule represents a database data masking rule. +type DataMaskingRule struct { + autorest.Response `json:"-"` + // DataMaskingRuleProperties - The properties of the resource. + *DataMaskingRuleProperties `json:"properties,omitempty"` + // Location - The location of the data masking rule. + Location *string `json:"location,omitempty"` + // Kind - The kind of Data Masking Rule. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if dmr.Location != nil { + objectMap["location"] = dmr.Location + } + if dmr.Kind != nil { + objectMap["kind"] = dmr.Kind + } + if dmr.ID != nil { + objectMap["id"] = dmr.ID + } + if dmr.Name != nil { + objectMap["name"] = dmr.Name + } + if dmr.Type != nil { + objectMap["type"] = dmr.Type + } + 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 - 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"` +} + +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceLevelObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // Status - 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"` +} + +// ElasticPool represents a database elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // ElasticPoolProperties - The properties representing the resource. + *ElasticPoolProperties `json:"properties,omitempty"` + // Kind - Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = ep.Kind + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.ID != nil { + objectMap["id"] = ep.ID + } + if ep.Name != nil { + objectMap["name"] = ep.Name + } + if ep.Type != nil { + objectMap["type"] = ep.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epa.ID != nil { + objectMap["id"] = epa.ID + } + if epa.Name != nil { + objectMap["name"] = epa.Name + } + if epa.Type != nil { + objectMap["type"] = epa.Type + } + 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 - The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedDatabaseDtuMax - The requested max DTU per database if available. + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + // RequestedDatabaseDtuMin - The requested min DTU per database if available. + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + // RequestedDtu - The requested DTU for the pool if available. + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + // RequestedElasticPoolName - The requested name for the elastic pool if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // RequestedStorageLimitInGB - The requested storage limit for the pool in GB if available. + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + // ElasticPoolName - The name of the elastic pool. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ServerName - The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - The current state of the operation. + State *string `json:"state,omitempty"` + // RequestedStorageLimitInMB - The requested storage limit in MB. + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + // RequestedDatabaseDtuGuarantee - The requested per database DTU guarantee. + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + // RequestedDatabaseDtuCap - The requested per database DTU cap. + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + // RequestedDtuGuarantee - The requested DTU guarantee. + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epda.ID != nil { + objectMap["id"] = epda.ID + } + if epda.Name != nil { + objectMap["name"] = epda.Name + } + if epda.Type != nil { + objectMap["type"] = epda.Type + } + 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 - The database name. + DatabaseName *string `json:"databaseName,omitempty"` + // EndTime - The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedElasticPoolName - The name for the elastic pool the database is moving into if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // CurrentElasticPoolName - The name of the current elastic pool the database is in if available. + CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` + // CurrentServiceObjective - The name of the current service objective if available. + CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` + // RequestedServiceObjective - The name of the requested service objective if available. + RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` + // ServerName - The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - The current state of the operation. + State *string `json:"state,omitempty"` +} + +// ElasticPoolDtuCapability the Elastic Pool DTU capability. +type ElasticPoolDtuCapability struct { + // Limit - The DTU limit for the pool. + Limit *int32 `json:"limit,omitempty"` + // MaxDatabaseCount - The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - The included (free) max size for this DTU. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxDtus - The list of supported per database max DTUs. + SupportedPerDatabaseMaxDtus *[]ElasticPoolPerDatabaseMaxDtuCapability `json:"supportedPerDatabaseMaxDtus,omitempty"` + // Status - 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"` +} + +// ElasticPoolEditionCapability the elastic pool edition capability. +type ElasticPoolEditionCapability struct { + // Name - The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolDtus - The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolDtus *[]ElasticPoolDtuCapability `json:"supportedElasticPoolDtus,omitempty"` + // Status - 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"` +} + +// 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 - The maximum DTUs per database. + Limit *int32 `json:"limit,omitempty"` + // SupportedPerDatabaseMinDtus - The list of supported min database DTUs. + SupportedPerDatabaseMinDtus *[]ElasticPoolPerDatabaseMinDtuCapability `json:"supportedPerDatabaseMinDtus,omitempty"` + // Status - 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"` +} + +// ElasticPoolPerDatabaseMinDtuCapability the minimum per-database DTU capability. +type ElasticPoolPerDatabaseMinDtuCapability struct { + // Limit - The minimum DTUs per database. + Limit *int32 `json:"limit,omitempty"` + // Status - 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"` +} + +// ElasticPoolProperties represents the properties of an elastic pool. +type ElasticPoolProperties struct { + // CreationDate - The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // State - 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' + 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"` +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsCreateOrUpdateFuture) Result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ElasticPoolsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsUpdateFuture) Result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epu.ID != nil { + objectMap["id"] = epu.ID + } + if epu.Name != nil { + objectMap["name"] = epu.Name + } + if epu.Type != nil { + objectMap["type"] = epu.Type + } + 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 - Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // EncryptionProtectorProperties - Resource properties. + *EncryptionProtectorProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = ep.Kind + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.EncryptionProtectorProperties != nil { + objectMap["properties"] = ep.EncryptionProtectorProperties + } + if ep.ID != nil { + objectMap["id"] = ep.ID + } + if ep.Name != nil { + objectMap["name"] = ep.Name + } + if ep.Type != nil { + objectMap["type"] = ep.Type + } + 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 - Array of results. + Value *[]EncryptionProtector `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector values. +type EncryptionProtectorListResultIterator struct { + i int + page EncryptionProtectorListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EncryptionProtectorListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr EncryptionProtectorListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer() (*http.Request, error) { + if eplr.NextLink == nil || len(to.String(eplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. +type EncryptionProtectorListResultPage struct { + fn func(EncryptionProtectorListResult) (EncryptionProtectorListResult, error) + eplr EncryptionProtectorListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EncryptionProtectorListResultPage) Next() error { + next, err := page.fn(page.eplr) + if err != nil { + return err + } + page.eplr = next + return nil +} + +// 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 +} + +// EncryptionProtectorProperties properties for an encryption protector execution. +type EncryptionProtectorProperties struct { + // Subregion - 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 - The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future EncryptionProtectorsCreateOrUpdateFuture) Result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // FailoverGroupProperties - Resource properties. + *FailoverGroupProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = fg.Location + } + if fg.Tags != nil { + objectMap["tags"] = fg.Tags + } + if fg.FailoverGroupProperties != nil { + objectMap["properties"] = fg.FailoverGroupProperties + } + if fg.ID != nil { + objectMap["id"] = fg.ID + } + if fg.Name != nil { + objectMap["name"] = fg.Name + } + if fg.Type != nil { + objectMap["type"] = fg.Type + } + 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 - Array of results. + Value *[]FailoverGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. +type FailoverGroupListResultIterator struct { + i int + page FailoverGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *FailoverGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (fglr FailoverGroupListResult) IsEmpty() bool { + return fglr.Value == nil || len(*fglr.Value) == 0 +} + +// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (fglr FailoverGroupListResult) failoverGroupListResultPreparer() (*http.Request, error) { + if fglr.NextLink == nil || len(to.String(fglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(fglr.NextLink))) +} + +// FailoverGroupListResultPage contains a page of FailoverGroup values. +type FailoverGroupListResultPage struct { + fn func(FailoverGroupListResult) (FailoverGroupListResult, error) + fglr FailoverGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *FailoverGroupListResultPage) Next() error { + next, err := page.fn(page.fglr) + if err != nil { + return err + } + page.fglr = next + return nil +} + +// 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 +} + +// 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 - Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - 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"` +} + +// 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsCreateOrUpdateFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type FailoverGroupsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsDeleteFuture) Result(client FailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsFailoverFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsFailoverFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsForceFailoverAllowDataLossFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.ForceFailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.ForceFailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type FailoverGroupsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsUpdateFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Kind of server that contains this firewall rule. + Kind *string `json:"kind,omitempty"` + // Location - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = fr.Kind + } + if fr.Location != nil { + objectMap["location"] = fr.Location + } + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + if fr.ID != nil { + objectMap["id"] = fr.ID + } + if fr.Name != nil { + objectMap["name"] = fr.Name + } + if fr.Type != nil { + objectMap["type"] = fr.Type + } + 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 - Kind of geo backup policy. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Backup policy location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if gbp.Kind != nil { + objectMap["kind"] = gbp.Kind + } + if gbp.Location != nil { + objectMap["location"] = gbp.Location + } + if gbp.ID != nil { + objectMap["id"] = gbp.ID + } + if gbp.Name != nil { + objectMap["name"] = gbp.Name + } + if gbp.Type != nil { + objectMap["type"] = gbp.Type + } + 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 - The storage type of the geo backup policy. + StorageType *string `json:"storageType,omitempty"` +} + +// ImportExportResponse response for Import/Export Get operation. +type ImportExportResponse struct { + autorest.Response `json:"-"` + // ImportExportResponseProperties - The import/export operation properties. + *ImportExportResponseProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if ier.ID != nil { + objectMap["id"] = ier.ID + } + if ier.Name != nil { + objectMap["name"] = ier.Name + } + if ier.Type != nil { + objectMap["type"] = ier.Type + } + 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 - The request type of the operation. + RequestType *string `json:"requestType,omitempty"` + // RequestID - The request type of the operation. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // ServerName - The name of the server. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The name of the database. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - The status message returned from the server. + Status *string `json:"status,omitempty"` + // LastModifiedTime - The operation status last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // QueuedTime - The operation queued time. + QueuedTime *string `json:"queuedTime,omitempty"` + // BlobURI - The blob uri. + BlobURI *string `json:"blobUri,omitempty"` + // ErrorMessage - The error message returned from the server. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// 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. Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2' + Edition DatabaseEdition `json:"edition,omitempty"` + // ServiceObjectiveName - The name of the service objective to assign to the database. Possible values include: 'ServiceObjectiveNameSystem', 'ServiceObjectiveNameSystem0', 'ServiceObjectiveNameSystem1', 'ServiceObjectiveNameSystem2', 'ServiceObjectiveNameSystem3', 'ServiceObjectiveNameSystem4', 'ServiceObjectiveNameSystem2L', 'ServiceObjectiveNameSystem3L', 'ServiceObjectiveNameSystem4L', 'ServiceObjectiveNameFree', 'ServiceObjectiveNameBasic', 'ServiceObjectiveNameS0', 'ServiceObjectiveNameS1', 'ServiceObjectiveNameS2', 'ServiceObjectiveNameS3', 'ServiceObjectiveNameS4', 'ServiceObjectiveNameS6', 'ServiceObjectiveNameS7', 'ServiceObjectiveNameS9', 'ServiceObjectiveNameS12', 'ServiceObjectiveNameP1', 'ServiceObjectiveNameP2', 'ServiceObjectiveNameP3', 'ServiceObjectiveNameP4', 'ServiceObjectiveNameP6', 'ServiceObjectiveNameP11', 'ServiceObjectiveNameP15', 'ServiceObjectiveNamePRS1', 'ServiceObjectiveNamePRS2', 'ServiceObjectiveNamePRS4', 'ServiceObjectiveNamePRS6', 'ServiceObjectiveNameDW100', 'ServiceObjectiveNameDW200', 'ServiceObjectiveNameDW300', 'ServiceObjectiveNameDW400', 'ServiceObjectiveNameDW500', 'ServiceObjectiveNameDW600', 'ServiceObjectiveNameDW1000', 'ServiceObjectiveNameDW1200', 'ServiceObjectiveNameDW1000c', 'ServiceObjectiveNameDW1500', 'ServiceObjectiveNameDW1500c', 'ServiceObjectiveNameDW2000', 'ServiceObjectiveNameDW2000c', 'ServiceObjectiveNameDW3000', 'ServiceObjectiveNameDW2500c', 'ServiceObjectiveNameDW3000c', 'ServiceObjectiveNameDW6000', 'ServiceObjectiveNameDW5000c', 'ServiceObjectiveNameDW6000c', 'ServiceObjectiveNameDW7500c', 'ServiceObjectiveNameDW10000c', 'ServiceObjectiveNameDW15000c', 'ServiceObjectiveNameDW30000c', 'ServiceObjectiveNameDS100', 'ServiceObjectiveNameDS200', 'ServiceObjectiveNameDS300', 'ServiceObjectiveNameDS400', 'ServiceObjectiveNameDS500', 'ServiceObjectiveNameDS600', 'ServiceObjectiveNameDS1000', 'ServiceObjectiveNameDS1200', 'ServiceObjectiveNameDS1500', 'ServiceObjectiveNameDS2000', 'ServiceObjectiveNameElasticPool' + ServiceObjectiveName ServiceObjectiveName `json:"serviceObjectiveName,omitempty"` + // MaxSizeBytes - The maximum size for the newly imported database. + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // 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 - The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // Status - 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"` +} + +// 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 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = mi.Tags + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.ID != nil { + objectMap["id"] = mi.ID + } + if mi.Name != nil { + objectMap["name"] = mi.Name + } + if mi.Type != nil { + objectMap["type"] = mi.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + 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 - Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer() (*http.Request, error) { + if milr.NextLink == nil || len(to.String(milr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceListResultPage) Next() error { + next, err := page.fn(page.milr) + if err != nil { + return err + } + page.milr = next + return nil +} + +// 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 +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // FullyQualifiedDomainName - 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 - The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' and 'BasePrice'. + LicenseType *string `json:"licenseType,omitempty"` + // VCores - The number of VCores. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - The maximum storage size in GB. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesCreateOrUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesDeleteFuture) Result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "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 - The maximum size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes' + Unit MaxSizeUnits `json:"unit,omitempty"` + // Status - 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"` +} + +// Metric database metrics. +type Metric struct { + // StartTime - The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - The time step to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' + Unit UnitType `json:"unit,omitempty"` + // Name - The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MetricAvailability a metric availability value. +type MetricAvailability struct { + // Retention - The length of retention for the database metric. + Retention *string `json:"retention,omitempty"` + // TimeGrain - The granularity of the database metric. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MetricDefinition a database metric definition. +type MetricDefinition struct { + // Name - The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // PrimaryAggregationType - The primary aggregation type defining how metric values are displayed. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // ResourceURI - The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' + Unit UnitDefinitionType `json:"unit,omitempty"` + // MetricAvailabilities - The list of database metric availabities for the metric. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` +} + +// 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 - The name of the database metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - The friendly name of the database metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MetricValue represents database metrics. +type MetricValue struct { + // Count - The number of values for the metric. + Count *float64 `json:"count,omitempty"` + // Average - The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// Operation SQL REST API operation definition. +type Operation struct { + // Name - The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - The localized display information for this particular operation / action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The intended executor of the operation. Possible values include: 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - 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{}) + if o.Name != nil { + objectMap["name"] = o.Name + } + if o.Display != nil { + objectMap["display"] = o.Display + } + if o.Origin != "" { + objectMap["origin"] = o.Origin + } + if o.Properties != nil { + objectMap["properties"] = o.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - The localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - The localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` + // Operation - The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - The localized friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// OperationImpact the impact of an operation, both in absolute and relative terms. +type OperationImpact struct { + // Name - The name of the impact dimension. + Name *string `json:"name,omitempty"` + // Unit - The unit in which estimated impact to dimension is measured. + Unit *string `json:"unit,omitempty"` + // ChangeValueAbsolute - The absolute impact to dimension. + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - The relative impact to dimension (null if not applicable) + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// OperationListResult result of the request to list SQL operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]Operation `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// 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 +} + +// PartnerInfo partner server information for the failover group. +type PartnerInfo struct { + // ID - Resource identifier of the partner server. + ID *string `json:"id,omitempty"` + // Location - Geo location of the partner server. + Location *string `json:"location,omitempty"` + // ReplicationRole - Replication role of the partner server. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// PerformanceLevelCapability the performance level capability. +type PerformanceLevelCapability struct { + // Value - Performance level value. + Value *int32 `json:"value,omitempty"` + // Unit - Unit type used to measure service objective performance level. Possible values include: 'DTU' + Unit PerformanceLevelUnit `json:"unit,omitempty"` +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// RecommendedIndex represents a database recommended index. +type RecommendedIndex struct { + // RecommendedIndexProperties - The properties representing the resource. + *RecommendedIndexProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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{}) + if ri.RecommendedIndexProperties != nil { + objectMap["properties"] = ri.RecommendedIndexProperties + } + if ri.ID != nil { + objectMap["id"] = ri.ID + } + if ri.Name != nil { + objectMap["name"] = ri.Name + } + if ri.Type != nil { + objectMap["type"] = ri.Type + } + 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 - The proposed index action. You can create a missing index, drop an unused index, or rebuild an existing index to improve its performance. Possible values include: 'Create', 'Drop', 'Rebuild' + Action RecommendedIndexAction `json:"action,omitempty"` + // State - The current recommendation state. Possible values include: 'Active', 'Pending', 'Executing', 'Verifying', 'PendingRevert', 'Reverting', 'Reverted', 'Ignored', 'Expired', 'Blocked', 'Success' + State RecommendedIndexState `json:"state,omitempty"` + // Created - The UTC datetime showing when this resource was created (ISO8601 format). + Created *date.Time `json:"created,omitempty"` + // LastModified - The UTC datetime of when was this resource last changed (ISO8601 format). + LastModified *date.Time `json:"lastModified,omitempty"` + // IndexType - The type of index (CLUSTERED, NONCLUSTERED, COLUMNSTORE, CLUSTERED COLUMNSTORE). Possible values include: 'CLUSTERED', 'NONCLUSTERED', 'COLUMNSTORE', 'CLUSTEREDCOLUMNSTORE' + IndexType RecommendedIndexType `json:"indexType,omitempty"` + // Schema - The schema where table to build index over resides + Schema *string `json:"schema,omitempty"` + // Table - The table on which to build index. + Table *string `json:"table,omitempty"` + // Columns - Columns over which to build index + Columns *[]string `json:"columns,omitempty"` + // IncludedColumns - The list of column names to be included in the index + IncludedColumns *[]string `json:"includedColumns,omitempty"` + // IndexScript - The full build index script + IndexScript *string `json:"indexScript,omitempty"` + // EstimatedImpact - The estimated impact of doing recommended index action. + EstimatedImpact *[]OperationImpact `json:"estimatedImpact,omitempty"` + // ReportedImpact - The values reported after index action is complete. + ReportedImpact *[]OperationImpact `json:"reportedImpact,omitempty"` +} + +// RecoverableDatabase a recoverable database +type RecoverableDatabase struct { + autorest.Response `json:"-"` + // RecoverableDatabaseProperties - The properties of a recoverable database + *RecoverableDatabaseProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if rd.ID != nil { + objectMap["id"] = rd.ID + } + if rd.Name != nil { + objectMap["name"] = rd.Name + } + if rd.Type != nil { + objectMap["type"] = rd.Type + } + 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 - The edition of the database + Edition *string `json:"edition,omitempty"` + // ServiceLevelObjective - The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // LastAvailableBackupDate - The last available backup date of the database (ISO8601 format) + LastAvailableBackupDate *date.Time `json:"lastAvailableBackupDate,omitempty"` +} + +// ReplicationLink represents a database replication link. +type ReplicationLink struct { + autorest.Response `json:"-"` + // Location - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = rl.Location + } + if rl.ReplicationLinkProperties != nil { + objectMap["properties"] = rl.ReplicationLinkProperties + } + if rl.ID != nil { + objectMap["id"] = rl.ID + } + if rl.Name != nil { + objectMap["name"] = rl.Name + } + if rl.Type != nil { + objectMap["type"] = rl.Type + } + 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 - Legacy value indicating whether termination is allowed. Currently always returns true. + IsTerminationAllowed *bool `json:"isTerminationAllowed,omitempty"` + // ReplicationMode - Replication mode of this replication link. + ReplicationMode *string `json:"replicationMode,omitempty"` + // PartnerServer - The name of the server hosting the partner database. + PartnerServer *string `json:"partnerServer,omitempty"` + // PartnerDatabase - The name of the partner database. + PartnerDatabase *string `json:"partnerDatabase,omitempty"` + // PartnerLocation - The Azure Region of the partner database. + PartnerLocation *string `json:"partnerLocation,omitempty"` + // Role - The role of the database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + Role ReplicationRole `json:"role,omitempty"` + // PartnerRole - The role of the partner database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + PartnerRole ReplicationRole `json:"partnerRole,omitempty"` + // StartTime - The start time for the replication link. + StartTime *date.Time `json:"startTime,omitempty"` + // PercentComplete - The percentage of seeding complete for the replication link. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ReplicationState - The replication state for the replication link. Possible values include: 'PENDING', 'SEEDING', 'CATCHUP', 'SUSPENDED' + ReplicationState ReplicationState `json:"replicationState,omitempty"` +} + +// ReplicationLinksFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ReplicationLinksFailoverAllowDataLossFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ReplicationLinksFailoverAllowDataLossFuture) Result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.FailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.FailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReplicationLinksFailoverFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ReplicationLinksFailoverFuture) Result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure responding to request") + } + return +} + +// Resource ARM resource. +type Resource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// ResourceIdentity azure Active Directory identity configuration for a resource. +type ResourceIdentity struct { + // PrincipalID - 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 IdentityType `json:"type,omitempty"` + // TenantID - The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// RestorableDroppedDatabase a restorable dropped database +type RestorableDroppedDatabase struct { + autorest.Response `json:"-"` + // Location - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = rdd.Location + } + if rdd.RestorableDroppedDatabaseProperties != nil { + objectMap["properties"] = rdd.RestorableDroppedDatabaseProperties + } + if rdd.ID != nil { + objectMap["id"] = rdd.ID + } + if rdd.Name != nil { + objectMap["name"] = rdd.Name + } + if rdd.Type != nil { + objectMap["type"] = rdd.Type + } + 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 - The name of the database + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - The edition of the database + Edition *string `json:"edition,omitempty"` + // MaxSizeBytes - The max size in bytes of the database + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // ServiceLevelObjective - The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // CreationDate - The creation date of the database (ISO8601 format) + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - The deletion date of the database (ISO8601 format) + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - The earliest restore date of the database (ISO8601 format) + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// RestorePoint a database restore point. +type RestorePoint struct { + // RestorePointProperties - The properties of the restore point. + *RestorePointProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if rp.ID != nil { + objectMap["id"] = rp.ID + } + if rp.Name != nil { + objectMap["name"] = rp.Name + } + if rp.Type != nil { + objectMap["type"] = rp.Type + } + 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 - The restore point type of the database restore point. Possible values include: 'DISCRETE', 'CONTINUOUS' + RestorePointType RestorePointType `json:"restorePointType,omitempty"` + // RestorePointCreationDate - Restore point creation time (ISO8601 format). Populated when restorePointType = CONTINUOUS. Null otherwise. + RestorePointCreationDate *date.Time `json:"restorePointCreationDate,omitempty"` + // EarliestRestoreDate - Earliest restore time (ISO8601 format). Populated when restorePointType = DISCRETE. Null otherwise. + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// 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 - 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"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = s.Kind + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Type != nil { + objectMap["type"] = s.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if saaa.ID != nil { + objectMap["id"] = saaa.ID + } + if saaa.Name != nil { + objectMap["name"] = saaa.Name + } + if saaa.Type != nil { + objectMap["type"] = saaa.Type + } + 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerAzureADAdministratorsCreateOrUpdateFuture) Result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + saaa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + saaa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerAzureADAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerAzureADAdministratorsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerAzureADAdministratorsDeleteFuture) Result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + saaa, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure sending request") + return + } + saaa, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerCommunicationLink server communication link. +type ServerCommunicationLink struct { + autorest.Response `json:"-"` + // ServerCommunicationLinkProperties - The properties of resource. + *ServerCommunicationLinkProperties `json:"properties,omitempty"` + // Location - Communication link location. + Location *string `json:"location,omitempty"` + // Kind - Communication link kind. This property is used for Azure Portal metadata. + Kind *string `json:"kind,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if scl.Location != nil { + objectMap["location"] = scl.Location + } + if scl.Kind != nil { + objectMap["kind"] = scl.Kind + } + if scl.ID != nil { + objectMap["id"] = scl.ID + } + if scl.Name != nil { + objectMap["name"] = scl.Name + } + if scl.Type != nil { + objectMap["type"] = scl.Type + } + 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 - The state. + State *string `json:"state,omitempty"` + // PartnerServer - The name of the partner server. + PartnerServer *string `json:"partnerServer,omitempty"` +} + +// ServerCommunicationLinksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerCommunicationLinksCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerCommunicationLinksCreateOrUpdateFuture) Result(client ServerCommunicationLinksClient) (scl ServerCommunicationLink, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return scl, azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + scl, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + scl, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerConnectionPolicy a server secure connection policy. +type ServerConnectionPolicy struct { + autorest.Response `json:"-"` + // Kind - Metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ServerConnectionPolicyProperties - The properties of the server secure connection policy. + *ServerConnectionPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = scp.Kind + } + if scp.Location != nil { + objectMap["location"] = scp.Location + } + if scp.ServerConnectionPolicyProperties != nil { + objectMap["properties"] = scp.ServerConnectionPolicyProperties + } + if scp.ID != nil { + objectMap["id"] = scp.ID + } + if scp.Name != nil { + objectMap["name"] = scp.Name + } + if scp.Type != nil { + objectMap["type"] = scp.Type + } + 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 - Resource location. + Location *string `json:"location,omitempty"` + // ServerKeyProperties - Resource properties. + *ServerKeyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = sk.Location + } + if sk.ServerKeyProperties != nil { + objectMap["properties"] = sk.ServerKeyProperties + } + if sk.ID != nil { + objectMap["id"] = sk.ID + } + if sk.Name != nil { + objectMap["name"] = sk.Name + } + if sk.Type != nil { + objectMap["type"] = sk.Type + } + 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 - Array of results. + Value *[]ServerKey `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerKeyListResultIterator provides access to a complete listing of ServerKey values. +type ServerKeyListResultIterator struct { + i int + page ServerKeyListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerKeyListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sklr ServerKeyListResult) IsEmpty() bool { + return sklr.Value == nil || len(*sklr.Value) == 0 +} + +// serverKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sklr ServerKeyListResult) serverKeyListResultPreparer() (*http.Request, error) { + if sklr.NextLink == nil || len(to.String(sklr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sklr.NextLink))) +} + +// ServerKeyListResultPage contains a page of ServerKey values. +type ServerKeyListResultPage struct { + fn func(ServerKeyListResult) (ServerKeyListResult, error) + sklr ServerKeyListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerKeyListResultPage) Next() error { + next, err := page.fn(page.sklr) + if err != nil { + return err + } + page.sklr = next + return nil +} + +// 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 +} + +// ServerKeyProperties properties for a server key execution. +type ServerKeyProperties struct { + // Subregion - 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"` +} + +// ServerKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerKeysCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerKeysCreateOrUpdateFuture) Result(client ServerKeysClient) (sk ServerKey, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sk, azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sk, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sk, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerKeysDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServerKeysDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerKeysDeleteFuture) Result(client ServerKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]Server `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer() (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerListResultPage) Next() error { + next, err := page.fn(page.slr) + if err != nil { + return err + } + page.slr = next + return nil +} + +// 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 +} + +// 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 - The state of the server. + State *string `json:"state,omitempty"` + // FullyQualifiedDomainName - The fully qualified domain name of the server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` +} + +// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServersCreateOrUpdateFuture) Result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return s, azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + s, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + s, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServersDeleteFuture) Result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServersUpdateFuture) Result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return s, azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + s, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure sending request") + return + } + s, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Name of the server usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - The metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - The current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - The current limit of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - The units of the metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - The next reset time for the metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// 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 - The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` + // Status - 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"` +} + +// ServiceLevelObjectiveCapability the service objectives capability. +type ServiceLevelObjectiveCapability struct { + // ID - The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // Name - The service objective name. + Name *string `json:"name,omitempty"` + // SupportedMaxSizes - The list of supported maximum database sizes for this service objective. + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + // PerformanceLevel - The performance level of the service objective capability. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // IncludedMaxSize - The included (free) max size for this service level objective. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // Status - 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"` +} + +// ServiceObjective represents a database service objective. +type ServiceObjective struct { + autorest.Response `json:"-"` + // ServiceObjectiveProperties - Represents the properties of the resource. + *ServiceObjectiveProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if so.ID != nil { + objectMap["id"] = so.ID + } + if so.Name != nil { + objectMap["name"] = so.Name + } + if so.Type != nil { + objectMap["type"] = so.Type + } + 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 - The name for the service objective. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // IsDefault - Gets whether the service level objective is the default service objective. + IsDefault *bool `json:"isDefault,omitempty"` + // IsSystem - Gets whether the service level objective is a system service objective. + IsSystem *bool `json:"isSystem,omitempty"` + // Description - The description for the service level objective. + Description *string `json:"description,omitempty"` + // Enabled - Gets whether the service level objective is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// ServiceTierAdvisor represents a Service Tier Advisor. +type ServiceTierAdvisor struct { + autorest.Response `json:"-"` + // ServiceTierAdvisorProperties - The properites representing the resource. + *ServiceTierAdvisorProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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{}) + if sta.ServiceTierAdvisorProperties != nil { + objectMap["properties"] = sta.ServiceTierAdvisorProperties + } + if sta.ID != nil { + objectMap["id"] = sta.ID + } + if sta.Name != nil { + objectMap["name"] = sta.Name + } + if sta.Type != nil { + objectMap["type"] = sta.Type + } + 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 - The observation period start (ISO8601 format). + ObservationPeriodStart *date.Time `json:"observationPeriodStart,omitempty"` + // ObservationPeriodEnd - The observation period start (ISO8601 format). + ObservationPeriodEnd *date.Time `json:"observationPeriodEnd,omitempty"` + // ActiveTimeRatio - The activeTimeRatio for service tier advisor. + ActiveTimeRatio *float64 `json:"activeTimeRatio,omitempty"` + // MinDtu - Gets or sets minDtu for service tier advisor. + MinDtu *float64 `json:"minDtu,omitempty"` + // AvgDtu - Gets or sets avgDtu for service tier advisor. + AvgDtu *float64 `json:"avgDtu,omitempty"` + // MaxDtu - Gets or sets maxDtu for service tier advisor. + MaxDtu *float64 `json:"maxDtu,omitempty"` + // MaxSizeInGB - Gets or sets maxSizeInGB for service tier advisor. + MaxSizeInGB *float64 `json:"maxSizeInGB,omitempty"` + // ServiceLevelObjectiveUsageMetrics - Gets or sets serviceLevelObjectiveUsageMetrics for the service tier advisor. + ServiceLevelObjectiveUsageMetrics *[]SloUsageMetric `json:"serviceLevelObjectiveUsageMetrics,omitempty"` + // CurrentServiceLevelObjective - Gets or sets currentServiceLevelObjective for service tier advisor. + CurrentServiceLevelObjective *string `json:"currentServiceLevelObjective,omitempty"` + // CurrentServiceLevelObjectiveID - Gets or sets currentServiceLevelObjectiveId for service tier advisor. + CurrentServiceLevelObjectiveID *uuid.UUID `json:"currentServiceLevelObjectiveId,omitempty"` + // UsageBasedRecommendationServiceLevelObjective - Gets or sets usageBasedRecommendationServiceLevelObjective for service tier advisor. + UsageBasedRecommendationServiceLevelObjective *string `json:"usageBasedRecommendationServiceLevelObjective,omitempty"` + // UsageBasedRecommendationServiceLevelObjectiveID - Gets or sets usageBasedRecommendationServiceLevelObjectiveId for service tier advisor. + UsageBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"usageBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjective - Gets or sets databaseSizeBasedRecommendationServiceLevelObjective for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjective *string `json:"databaseSizeBasedRecommendationServiceLevelObjective,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjectiveID - Gets or sets databaseSizeBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"databaseSizeBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjective - Gets or sets disasterPlanBasedRecommendationServiceLevelObjective for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjective *string `json:"disasterPlanBasedRecommendationServiceLevelObjective,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjectiveID - Gets or sets disasterPlanBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"disasterPlanBasedRecommendationServiceLevelObjectiveId,omitempty"` + // OverallRecommendationServiceLevelObjective - Gets or sets overallRecommendationServiceLevelObjective for service tier advisor. + OverallRecommendationServiceLevelObjective *string `json:"overallRecommendationServiceLevelObjective,omitempty"` + // OverallRecommendationServiceLevelObjectiveID - Gets or sets overallRecommendationServiceLevelObjectiveId for service tier advisor. + OverallRecommendationServiceLevelObjectiveID *uuid.UUID `json:"overallRecommendationServiceLevelObjectiveId,omitempty"` + // Confidence - Gets or sets confidence for service tier advisor. + Confidence *float64 `json:"confidence,omitempty"` +} + +// 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 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 - 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 - The serviceLevelObjectiveId for SLO usage metric. + ServiceLevelObjectiveID *uuid.UUID `json:"serviceLevelObjectiveId,omitempty"` + // InRangeTimeRatio - Gets or sets inRangeTimeRatio for SLO usage metric. + InRangeTimeRatio *float64 `json:"inRangeTimeRatio,omitempty"` +} + +// SubscriptionUsage usage Metric of a Subscription in a Location. +type SubscriptionUsage struct { + autorest.Response `json:"-"` + // SubscriptionUsageProperties - Resource properties. + *SubscriptionUsageProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if su.ID != nil { + objectMap["id"] = su.ID + } + if su.Name != nil { + objectMap["name"] = su.Name + } + if su.Type != nil { + objectMap["type"] = su.Type + } + 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 - Array of results. + Value *[]SubscriptionUsage `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SubscriptionUsageListResultIterator provides access to a complete listing of SubscriptionUsage values. +type SubscriptionUsageListResultIterator struct { + i int + page SubscriptionUsageListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SubscriptionUsageListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sulr SubscriptionUsageListResult) IsEmpty() bool { + return sulr.Value == nil || len(*sulr.Value) == 0 +} + +// subscriptionUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sulr SubscriptionUsageListResult) subscriptionUsageListResultPreparer() (*http.Request, error) { + if sulr.NextLink == nil || len(to.String(sulr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sulr.NextLink))) +} + +// SubscriptionUsageListResultPage contains a page of SubscriptionUsage values. +type SubscriptionUsageListResultPage struct { + fn func(SubscriptionUsageListResult) (SubscriptionUsageListResult, error) + sulr SubscriptionUsageListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SubscriptionUsageListResultPage) Next() error { + next, err := page.fn(page.sulr) + if err != nil { + return err + } + page.sulr = next + return nil +} + +// 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 +} + +// SubscriptionUsageProperties properties of a subscription usage. +type SubscriptionUsageProperties struct { + // DisplayName - User-readable name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - Current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - Boundary value of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - Unit of the metric. + Unit *string `json:"unit,omitempty"` +} + +// SyncAgent an Azure SQL Database sync agent. +type SyncAgent struct { + autorest.Response `json:"-"` + // SyncAgentProperties - Resource properties. + *SyncAgentProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sa.ID != nil { + objectMap["id"] = sa.ID + } + if sa.Name != nil { + objectMap["name"] = sa.Name + } + if sa.Type != nil { + objectMap["type"] = sa.Type + } + 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 - Key of sync agent. + SyncAgentKey *string `json:"syncAgentKey,omitempty"` +} + +// SyncAgentLinkedDatabase an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabase struct { + // SyncAgentLinkedDatabaseProperties - Resource properties. + *SyncAgentLinkedDatabaseProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sald.ID != nil { + objectMap["id"] = sald.ID + } + if sald.Name != nil { + objectMap["name"] = sald.Name + } + if sald.Type != nil { + objectMap["type"] = sald.Type + } + 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 - Array of results. + Value *[]SyncAgentLinkedDatabase `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncAgentLinkedDatabaseListResultIterator provides access to a complete listing of SyncAgentLinkedDatabase +// values. +type SyncAgentLinkedDatabaseListResultIterator struct { + i int + page SyncAgentLinkedDatabaseListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncAgentLinkedDatabaseListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (saldlr SyncAgentLinkedDatabaseListResult) IsEmpty() bool { + return saldlr.Value == nil || len(*saldlr.Value) == 0 +} + +// syncAgentLinkedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (saldlr SyncAgentLinkedDatabaseListResult) syncAgentLinkedDatabaseListResultPreparer() (*http.Request, error) { + if saldlr.NextLink == nil || len(to.String(saldlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(saldlr.NextLink))) +} + +// SyncAgentLinkedDatabaseListResultPage contains a page of SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultPage struct { + fn func(SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error) + saldlr SyncAgentLinkedDatabaseListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncAgentLinkedDatabaseListResultPage) Next() error { + next, err := page.fn(page.saldlr) + if err != nil { + return err + } + page.saldlr = next + return nil +} + +// 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 +} + +// SyncAgentLinkedDatabaseProperties properties of an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabaseProperties struct { + // DatabaseType - Type of the sync agent linked database. Possible values include: 'AzureSQLDatabase', 'SQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // DatabaseID - Id of the sync agent linked database. + DatabaseID *string `json:"databaseId,omitempty"` + // Description - Description of the sync agent linked database. + Description *string `json:"description,omitempty"` + // ServerName - Server name of the sync agent linked database. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - Database name of the sync agent linked database. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - User name of the sync agent linked database. + UserName *string `json:"userName,omitempty"` +} + +// SyncAgentListResult a list of sync agents. +type SyncAgentListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncAgent `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncAgentListResultIterator provides access to a complete listing of SyncAgent values. +type SyncAgentListResultIterator struct { + i int + page SyncAgentListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncAgentListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (salr SyncAgentListResult) IsEmpty() bool { + return salr.Value == nil || len(*salr.Value) == 0 +} + +// syncAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (salr SyncAgentListResult) syncAgentListResultPreparer() (*http.Request, error) { + if salr.NextLink == nil || len(to.String(salr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(salr.NextLink))) +} + +// SyncAgentListResultPage contains a page of SyncAgent values. +type SyncAgentListResultPage struct { + fn func(SyncAgentListResult) (SyncAgentListResult, error) + salr SyncAgentListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncAgentListResultPage) Next() error { + next, err := page.fn(page.salr) + if err != nil { + return err + } + page.salr = next + return nil +} + +// 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 +} + +// SyncAgentProperties properties of an Azure SQL Database sync agent. +type SyncAgentProperties struct { + // Name - 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 - Last alive time of the sync agent. + LastAliveTime *date.Time `json:"lastAliveTime,omitempty"` + // State - State of the sync agent. Possible values include: 'Online', 'Offline', 'NeverConnected' + State SyncAgentState `json:"state,omitempty"` + // IsUpToDate - If the sync agent version is up to date. + IsUpToDate *bool `json:"isUpToDate,omitempty"` + // ExpiryTime - Expiration time of the sync agent version. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Version - Version of the sync agent. + Version *string `json:"version,omitempty"` +} + +// SyncAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncAgentsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncAgentsCreateOrUpdateFuture) Result(client SyncAgentsClient) (sa SyncAgent, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sa, azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncAgentsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncAgentsDeleteFuture) Result(client SyncAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncDatabaseIDListResult a list of sync database ID properties. +type SyncDatabaseIDListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncDatabaseIDProperties `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncDatabaseIDListResultIterator provides access to a complete listing of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultIterator struct { + i int + page SyncDatabaseIDListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncDatabaseIDListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdilr SyncDatabaseIDListResult) IsEmpty() bool { + return sdilr.Value == nil || len(*sdilr.Value) == 0 +} + +// syncDatabaseIDListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdilr SyncDatabaseIDListResult) syncDatabaseIDListResultPreparer() (*http.Request, error) { + if sdilr.NextLink == nil || len(to.String(sdilr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdilr.NextLink))) +} + +// SyncDatabaseIDListResultPage contains a page of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultPage struct { + fn func(SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error) + sdilr SyncDatabaseIDListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncDatabaseIDListResultPage) Next() error { + next, err := page.fn(page.sdilr) + if err != nil { + return err + } + page.sdilr = next + return nil +} + +// 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 +} + +// SyncDatabaseIDProperties properties of the sync database id. +type SyncDatabaseIDProperties struct { + // ID - ARM resource id of sync database. + ID *string `json:"id,omitempty"` +} + +// SyncFullSchemaProperties properties of the database full schema. +type SyncFullSchemaProperties struct { + // Tables - List of tables in the database full schema. + Tables *[]SyncFullSchemaTable `json:"tables,omitempty"` + // LastUpdateTime - Last update time of the database schema. + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// SyncFullSchemaPropertiesListResult a list of sync schema properties. +type SyncFullSchemaPropertiesListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncFullSchemaProperties `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncFullSchemaPropertiesListResultIterator provides access to a complete listing of SyncFullSchemaProperties +// values. +type SyncFullSchemaPropertiesListResultIterator struct { + i int + page SyncFullSchemaPropertiesListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncFullSchemaPropertiesListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sfsplr SyncFullSchemaPropertiesListResult) IsEmpty() bool { + return sfsplr.Value == nil || len(*sfsplr.Value) == 0 +} + +// syncFullSchemaPropertiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sfsplr SyncFullSchemaPropertiesListResult) syncFullSchemaPropertiesListResultPreparer() (*http.Request, error) { + if sfsplr.NextLink == nil || len(to.String(sfsplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sfsplr.NextLink))) +} + +// SyncFullSchemaPropertiesListResultPage contains a page of SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultPage struct { + fn func(SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error) + sfsplr SyncFullSchemaPropertiesListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncFullSchemaPropertiesListResultPage) Next() error { + next, err := page.fn(page.sfsplr) + if err != nil { + return err + } + page.sfsplr = next + return nil +} + +// 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 +} + +// SyncFullSchemaTable properties of the table in the database full schema. +type SyncFullSchemaTable struct { + // Columns - List of columns in the table of database full schema. + Columns *[]SyncFullSchemaTableColumn `json:"columns,omitempty"` + // ErrorID - Error id of the table. + ErrorID *string `json:"errorId,omitempty"` + // HasError - If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // Name - Name of the table. + Name *string `json:"name,omitempty"` + // QuotedName - Quoted name of the table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncFullSchemaTableColumn properties of the column in the table of database full schema. +type SyncFullSchemaTableColumn struct { + // DataSize - Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - Data type of the column. + DataType *string `json:"dataType,omitempty"` + // ErrorID - Error id of the column. + ErrorID *string `json:"errorId,omitempty"` + // HasError - If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // IsPrimaryKey - If it is the primary key of the table. + IsPrimaryKey *bool `json:"isPrimaryKey,omitempty"` + // Name - Name of the column. + Name *string `json:"name,omitempty"` + // QuotedName - Quoted name of the column. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncGroup an Azure SQL Database sync group. +type SyncGroup struct { + autorest.Response `json:"-"` + // SyncGroupProperties - Resource properties. + *SyncGroupProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sg.ID != nil { + objectMap["id"] = sg.ID + } + if sg.Name != nil { + objectMap["name"] = sg.Name + } + if sg.Type != nil { + objectMap["type"] = sg.Type + } + 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 - Array of results. + Value *[]SyncGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncGroupListResultIterator provides access to a complete listing of SyncGroup values. +type SyncGroupListResultIterator struct { + i int + page SyncGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sglr SyncGroupListResult) IsEmpty() bool { + return sglr.Value == nil || len(*sglr.Value) == 0 +} + +// syncGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sglr SyncGroupListResult) syncGroupListResultPreparer() (*http.Request, error) { + if sglr.NextLink == nil || len(to.String(sglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sglr.NextLink))) +} + +// SyncGroupListResultPage contains a page of SyncGroup values. +type SyncGroupListResultPage struct { + fn func(SyncGroupListResult) (SyncGroupListResult, error) + sglr SyncGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncGroupListResultPage) Next() error { + next, err := page.fn(page.sglr) + if err != nil { + return err + } + page.sglr = next + return nil +} + +// 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 +} + +// SyncGroupLogListResult a list of sync group log properties. +type SyncGroupLogListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncGroupLogProperties `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncGroupLogListResultIterator provides access to a complete listing of SyncGroupLogProperties values. +type SyncGroupLogListResultIterator struct { + i int + page SyncGroupLogListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncGroupLogListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sgllr SyncGroupLogListResult) IsEmpty() bool { + return sgllr.Value == nil || len(*sgllr.Value) == 0 +} + +// syncGroupLogListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sgllr SyncGroupLogListResult) syncGroupLogListResultPreparer() (*http.Request, error) { + if sgllr.NextLink == nil || len(to.String(sgllr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sgllr.NextLink))) +} + +// SyncGroupLogListResultPage contains a page of SyncGroupLogProperties values. +type SyncGroupLogListResultPage struct { + fn func(SyncGroupLogListResult) (SyncGroupLogListResult, error) + sgllr SyncGroupLogListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncGroupLogListResultPage) Next() error { + next, err := page.fn(page.sgllr) + if err != nil { + return err + } + page.sgllr = next + return nil +} + +// 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 +} + +// SyncGroupLogProperties properties of an Azure SQL Database sync group log. +type SyncGroupLogProperties struct { + // Timestamp - Timestamp of the sync group log. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Type - Type of the sync group log. Possible values include: 'SyncGroupLogTypeAll', 'SyncGroupLogTypeError', 'SyncGroupLogTypeWarning', 'SyncGroupLogTypeSuccess' + Type SyncGroupLogType `json:"type,omitempty"` + // Source - Source of the sync group log. + Source *string `json:"source,omitempty"` + // Details - Details of the sync group log. + Details *string `json:"details,omitempty"` + // TracingID - TracingId of the sync group log. + TracingID *uuid.UUID `json:"tracingId,omitempty"` + // OperationStatus - OperationStatus of the sync group log. + OperationStatus *string `json:"operationStatus,omitempty"` +} + +// SyncGroupProperties properties of a sync group. +type SyncGroupProperties struct { + // Interval - Sync interval of the sync group. + Interval *int32 `json:"interval,omitempty"` + // LastSyncTime - 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 - 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"` +} + +// 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsCreateOrUpdateFuture) Result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncGroupsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsDeleteFuture) Result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncGroupsRefreshHubSchemaFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsRefreshHubSchemaFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsRefreshHubSchemaFuture) Result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.RefreshHubSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.RefreshHubSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncGroupsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsUpdateFuture) Result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure sending request") + return + } + sg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMember an Azure SQL Database sync member. +type SyncMember struct { + autorest.Response `json:"-"` + // SyncMemberProperties - Resource properties. + *SyncMemberProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sm.ID != nil { + objectMap["id"] = sm.ID + } + if sm.Name != nil { + objectMap["name"] = sm.Name + } + if sm.Type != nil { + objectMap["type"] = sm.Type + } + 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 - Array of results. + Value *[]SyncMember `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncMemberListResultIterator provides access to a complete listing of SyncMember values. +type SyncMemberListResultIterator struct { + i int + page SyncMemberListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncMemberListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (smlr SyncMemberListResult) IsEmpty() bool { + return smlr.Value == nil || len(*smlr.Value) == 0 +} + +// syncMemberListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smlr SyncMemberListResult) syncMemberListResultPreparer() (*http.Request, error) { + if smlr.NextLink == nil || len(to.String(smlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smlr.NextLink))) +} + +// SyncMemberListResultPage contains a page of SyncMember values. +type SyncMemberListResultPage struct { + fn func(SyncMemberListResult) (SyncMemberListResult, error) + smlr SyncMemberListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncMemberListResultPage) Next() error { + next, err := page.fn(page.smlr) + if err != nil { + return err + } + page.smlr = next + return nil +} + +// 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 +} + +// 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 - 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"` +} + +// SyncMembersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersCreateOrUpdateFuture) Result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sm, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sm, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMembersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncMembersDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersDeleteFuture) Result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMembersRefreshMemberSchemaFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersRefreshMemberSchemaFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersRefreshMemberSchemaFuture) Result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.RefreshMemberSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.RefreshMemberSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMembersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncMembersUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersUpdateFuture) Result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sm, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure sending request") + return + } + sm, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// TrackedResource ARM tracked top level resource. +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} + +// TransparentDataEncryption represents a database transparent data encryption configuration. +type TransparentDataEncryption struct { + autorest.Response `json:"-"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionProperties - Represents the properties of the resource. + *TransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = tde.Location + } + if tde.TransparentDataEncryptionProperties != nil { + objectMap["properties"] = tde.TransparentDataEncryptionProperties + } + if tde.ID != nil { + objectMap["id"] = tde.ID + } + if tde.Name != nil { + objectMap["name"] = tde.Name + } + if tde.Type != nil { + objectMap["type"] = tde.Type + } + 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 - Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionActivityProperties - Represents the properties of the resource. + *TransparentDataEncryptionActivityProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = tdea.Location + } + if tdea.TransparentDataEncryptionActivityProperties != nil { + objectMap["properties"] = tdea.TransparentDataEncryptionActivityProperties + } + if tdea.ID != nil { + objectMap["id"] = tdea.ID + } + if tdea.Name != nil { + objectMap["name"] = tdea.Name + } + if tdea.Type != nil { + objectMap["type"] = tdea.Type + } + 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 - The status of the database. Possible values include: 'Encrypting', 'Decrypting' + Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` + // PercentComplete - The percent complete of the transparent data encryption scan for a database. + PercentComplete *float64 `json:"percentComplete,omitempty"` +} + +// 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"` +} + +// VirtualNetworkRule a virtual network rule. +type VirtualNetworkRule struct { + autorest.Response `json:"-"` + // VirtualNetworkRuleProperties - Resource properties. + *VirtualNetworkRuleProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if vnr.ID != nil { + objectMap["id"] = vnr.ID + } + if vnr.Name != nil { + objectMap["name"] = vnr.Name + } + if vnr.Type != nil { + objectMap["type"] = vnr.Type + } + 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 - Array of results. + Value *[]VirtualNetworkRule `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// VirtualNetworkRuleListResultIterator provides access to a complete listing of VirtualNetworkRule values. +type VirtualNetworkRuleListResultIterator struct { + i int + page VirtualNetworkRuleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VirtualNetworkRuleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (vnrlr VirtualNetworkRuleListResult) IsEmpty() bool { + return vnrlr.Value == nil || len(*vnrlr.Value) == 0 +} + +// virtualNetworkRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vnrlr VirtualNetworkRuleListResult) virtualNetworkRuleListResultPreparer() (*http.Request, error) { + if vnrlr.NextLink == nil || len(to.String(vnrlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vnrlr.NextLink))) +} + +// VirtualNetworkRuleListResultPage contains a page of VirtualNetworkRule values. +type VirtualNetworkRuleListResultPage struct { + fn func(VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error) + vnrlr VirtualNetworkRuleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VirtualNetworkRuleListResultPage) Next() error { + next, err := page.fn(page.vnrlr) + if err != nil { + return err + } + page.vnrlr = next + return nil +} + +// 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 +} + +// 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 - Virtual Network Rule State. Possible values include: 'Initializing', 'InProgress', 'Ready', 'Deleting', 'Unknown' + State VirtualNetworkRuleState `json:"state,omitempty"` +} + +// VirtualNetworkRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future VirtualNetworkRulesCreateOrUpdateFuture) Result(client VirtualNetworkRulesClient) (vnr VirtualNetworkRule, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return vnr, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + vnr, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + vnr, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// VirtualNetworkRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualNetworkRulesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future VirtualNetworkRulesDeleteFuture) Result(client VirtualNetworkRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} diff --git a/services/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..d5c11bcff4cd --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/operations.go @@ -0,0 +1,128 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer() + 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) { + 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..54ac2e72645f --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/recoverabledatabases.go @@ -0,0 +1,178 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +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 +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database +func (client RecoverableDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RecoverableDatabase, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) GetResponder(resp *http.Response) (result RecoverableDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of recoverable databases +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client RecoverableDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableDatabaseListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) ListByServerResponder(resp *http.Response) (result RecoverableDatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..ad939db52788 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/replicationlinks.go @@ -0,0 +1,396 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewReplicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ReplicationLinksClient { + return ReplicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a database replication link. Cannot be done during failover. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database that has the replication link to be dropped. linkID is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover sets which replica database is primary by failing over from the current primary replica database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database that has the replication link to be failed over. linkID is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database that has the replication link to be failed over. linkID is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database replication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to get the link for. linkID is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) GetResponder(resp *http.Response) (result ReplicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists a database's replication links. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to retrieve links for. +func (client ReplicationLinksClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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/restorabledroppeddatabases.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorabledroppeddatabases.go new file mode 100644 index 000000000000..f8813b6301f5 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorabledroppeddatabases.go @@ -0,0 +1,179 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewRestorableDroppedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedDatabasesClient { + return RestorableDroppedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a deleted database that can be restored +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +// restorableDroppededDatabaseID is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of deleted databases that can be restored +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client RestorableDroppedDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RestorableDroppedDatabaseListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) ListByServerResponder(resp *http.Response) (result RestorableDroppedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..b76f8b09a4d9 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/restorepoints.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewRestorePointsClientWithBaseURI(baseURI string, subscriptionID string) RestorePointsClient { + return RestorePointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase gets a list of database restore points. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to get available restore points. +func (client RestorePointsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RestorePointListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..ebdf54805877 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverazureadadministrators.go @@ -0,0 +1,333 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. properties is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory Administrator. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAzureADAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministratorsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) DeleteResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAzureADAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministrator, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) GetResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of server Administrators. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAzureADAdministratorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerAdministratorListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) ListByServerResponder(resp *http.Response) (result ServerAdministratorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..cb2a1fdd2420 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/servercommunicationlinks.go @@ -0,0 +1,328 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewServerCommunicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServerCommunicationLinksClient { + return ServerCommunicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a server communication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. communicationLinkName is the +// name of the server communication link. parameters is 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 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) CreateOrUpdateResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server communication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. communicationLinkName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a server communication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. communicationLinkName is the +// name of the server communication link. +func (client ServerCommunicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result ServerCommunicationLink, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) GetResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server communication links. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerCommunicationLinksClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerCommunicationLinkListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) ListByServerResponder(resp *http.Response) (result ServerCommunicationLinkListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..1c02e43b9664 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverconnectionpolicies.go @@ -0,0 +1,181 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerConnectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerConnectionPoliciesClient { + return ServerConnectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's connection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the 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) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the server's secure connection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerConnectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) GetResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..1808980a453e --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverkeys.go @@ -0,0 +1,353 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerKeysClientWithBaseURI(baseURI string, subscriptionID string) ServerKeysClient { + return ServerKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server key. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. keyName is 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 is 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) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server key with the given name. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. keyName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server key. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. keyName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) GetResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server keys. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerKeysClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) ListByServerResponder(resp *http.Response) (result ServerKeyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerKeysClient) listByServerNextResults(lastResults ServerKeyListResult) (result ServerKeyListResult, err error) { + req, err := lastResults.serverKeyListResultPreparer() + 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) { + 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..9fe738737cea --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/servers.go @@ -0,0 +1,579 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +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 is the parameters to request for name availability. +func (client ServersClient) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequest) (result CheckNameAvailabilityResponse, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// server resource state. +func (client ServersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateOrUpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of servers in a resource groups. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer() + 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) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// server resource state. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (result ServersUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..327be0cd0973 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serverusages.go @@ -0,0 +1,109 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerUsagesClientWithBaseURI(baseURI string, subscriptionID string) ServerUsagesClient { + return ServerUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer returns server usages. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerUsagesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerUsageListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerUsagesClient) ListByServerResponder(resp *http.Response) (result ServerUsageListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..4dd06885c982 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/serviceobjectives.go @@ -0,0 +1,178 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServiceObjectivesClientWithBaseURI(baseURI string, subscriptionID string) ServiceObjectivesClient { + return ServiceObjectivesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database service objective. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. serviceObjectiveName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) GetResponder(resp *http.Response) (result ServiceObjective, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns database service objectives. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServiceObjectivesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServiceObjectiveListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) ListByServerResponder(resp *http.Response) (result ServiceObjectiveListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..581028cdec75 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/servicetieradvisors.go @@ -0,0 +1,181 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServiceTierAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) ServiceTierAdvisorsClient { + return ServiceTierAdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a service tier advisor. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// database. serviceTierAdvisorName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceTierAdvisorsClient) GetResponder(resp *http.Response) (result ServiceTierAdvisor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns service tier advisors for specified database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// database. +func (client ServiceTierAdvisorsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ServiceTierAdvisorListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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/subscriptionusages.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/subscriptionusages.go new file mode 100644 index 000000000000..6c014306f539 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/subscriptionusages.go @@ -0,0 +1,202 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSubscriptionUsagesClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionUsagesClient { + return SubscriptionUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a subscription usage metric. +// +// locationName is the name of the region where the resource is located. usageName is name of usage metric to +// return. +func (client SubscriptionUsagesClient) Get(ctx context.Context, locationName string, usageName string) (result SubscriptionUsage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) GetResponder(resp *http.Response) (result SubscriptionUsage, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// locationName is the name of the region where the resource is located. +func (client SubscriptionUsagesClient) ListByLocation(ctx context.Context, locationName string) (result SubscriptionUsageListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SubscriptionUsageListResult) (result SubscriptionUsageListResult, err error) { + req, err := lastResults.subscriptionUsageListResultPreparer() + 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) { + 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..97ebdca602ea --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncagents.go @@ -0,0 +1,516 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSyncAgentsClientWithBaseURI(baseURI string, subscriptionID string) SyncAgentsClient { + return SyncAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateKey generates a sync agent key. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentKeyProperties, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgent, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GetResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists sync agents in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. +func (client SyncAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListByServerResponder(resp *http.Response) (result SyncAgentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client SyncAgentsClient) listByServerNextResults(lastResults SyncAgentListResult) (result SyncAgentListResult, err error) { + req, err := lastResults.syncAgentListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// ListLinkedDatabases lists databases linked to a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncAgentLinkedDatabaseListResult) (result SyncAgentLinkedDatabaseListResult, err error) { + req, err := lastResults.syncAgentLinkedDatabaseListResultPreparer() + 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) { + 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..b08ba72a70d1 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncgroups.go @@ -0,0 +1,936 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient { + return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CancelSync cancels a sync group synchronization. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) GetResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists sync groups under a hub database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. +func (client SyncGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncGroupListResult) (result SyncGroupListResult, err error) { + req, err := lastResults.syncGroupListResultPreparer() + 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) { + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// ListHubSchemas gets a collection of hub database schemas. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer() + 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) { + result.page, err = client.ListHubSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListLogs gets a collection of sync group logs. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group. startTime is get +// logs generated after this time. endTime is get logs generated before this time. typeParameter is the types of +// logs to retrieve. continuationToken is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncGroupLogListResult) (result SyncGroupLogListResult, err error) { + req, err := lastResults.syncGroupLogListResultPreparer() + 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) { + result.page, err = client.ListLogs(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + return +} + +// ListSyncDatabaseIds gets a collection of sync database ids. +// +// locationName is the name of the region where the resource is located. +func (client SyncGroupsClient) ListSyncDatabaseIds(ctx context.Context, locationName string) (result SyncDatabaseIDListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncDatabaseIDListResult) (result SyncDatabaseIDListResult, err error) { + req, err := lastResults.syncDatabaseIDListResultPreparer() + 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) { + result.page, err = client.ListSyncDatabaseIds(ctx, locationName) + return +} + +// RefreshHubSchema refreshes a hub database schema. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// TriggerSync triggers a sync group synchronization. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) UpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..57554de42517 --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/syncmembers.go @@ -0,0 +1,612 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSyncMembersClientWithBaseURI(baseURI string, subscriptionID string) SyncMembersClient { + return SyncMembersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is the name of the sync member. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) CreateOrUpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) GetResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncMemberListResult) (result SyncMemberListResult, err error) { + req, err := lastResults.syncMemberListResultPreparer() + 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) { + result.page, err = client.ListBySyncGroup(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListMemberSchemas gets a sync member database schema. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer() + 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) { + result.page, err = client.ListMemberSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + return +} + +// RefreshMemberSchema refreshes a sync member database schema. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is the name of the sync member. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) UpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptionactivities.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptionactivities.go new file mode 100644 index 000000000000..818a30dddf7c --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptionactivities.go @@ -0,0 +1,114 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewTransparentDataEncryptionActivitiesClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionActivitiesClient { + return TransparentDataEncryptionActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByConfiguration returns a database's transparent data encryption operation result. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionActivitiesClient) ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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/transparentdataencryptions.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptions.go new file mode 100644 index 000000000000..87c20526f6ad --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/transparentdataencryptions.go @@ -0,0 +1,185 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewTransparentDataEncryptionsClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionsClient { + return TransparentDataEncryptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's transparent data encryption configuration. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which setting the transparent data encryption applies. parameters is 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) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's transparent data encryption configuration. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..21b61983166e --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/version.go @@ -0,0 +1,30 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " 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/virtualnetworkrules.go b/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualnetworkrules.go new file mode 100644 index 000000000000..336c296db9ff --- /dev/null +++ b/services/preview/sql/mgmt/2015-05-01-preview/sql/virtualnetworkrules.go @@ -0,0 +1,357 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewVirtualNetworkRulesClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkRulesClient { + return VirtualNetworkRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing virtual network rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. virtualNetworkRuleName is +// the name of the virtual network rule. parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the virtual network rule with the given name. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. virtualNetworkRuleName is +// the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRulesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual network rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. virtualNetworkRuleName is +// the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRule, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) GetResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of virtual network rules in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) ListByServerResponder(resp *http.Response) (result VirtualNetworkRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client VirtualNetworkRulesClient) listByServerNextResults(lastResults VirtualNetworkRuleListResult) (result VirtualNetworkRuleListResult, err error) { + req, err := lastResults.virtualNetworkRuleListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/backuplongtermretentionpolicies.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/backuplongtermretentionpolicies.go new file mode 100644 index 000000000000..0d976685371b --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/backuplongtermretentionpolicies.go @@ -0,0 +1,264 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupLongTermRetentionPoliciesClient 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 BackupLongTermRetentionPoliciesClient struct { + BaseClient +} + +// NewBackupLongTermRetentionPoliciesClient creates an instance of the BackupLongTermRetentionPoliciesClient client. +func NewBackupLongTermRetentionPoliciesClient(subscriptionID string) BackupLongTermRetentionPoliciesClient { + return NewBackupLongTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupLongTermRetentionPoliciesClientWithBaseURI creates an instance of the BackupLongTermRetentionPoliciesClient +// client. +func NewBackupLongTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupLongTermRetentionPoliciesClient { + return BackupLongTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database backup long term retention policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database parameters is the required parameters to update a backup long term retention policy +func (client BackupLongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupLongTermRetentionPolicy) (result BackupLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionPolicyProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionPolicyProperties.RecoveryServicesBackupPolicyResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.BackupLongTermRetentionPoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupLongTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupLongTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionPolicyName": 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 = "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}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}", 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 BackupLongTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future BackupLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns a database backup long term retention policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client BackupLongTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupLongTermRetentionPolicy, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "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.BackupLongTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupLongTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionPolicyName": 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 = "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}/backupLongTermRetentionPolicies/{backupLongTermRetentionPolicyName}", 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 BackupLongTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result BackupLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a database backup long term retention policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client BackupLongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupLongTermRetentionPolicyListResult, err error) { + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "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.BackupLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client BackupLongTermRetentionPoliciesClient) 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}/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 BackupLongTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result BackupLongTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/backuplongtermretentionvaults.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/backuplongtermretentionvaults.go new file mode 100644 index 000000000000..1a67bbc0210c --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/backuplongtermretentionvaults.go @@ -0,0 +1,259 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupLongTermRetentionVaultsClient 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 BackupLongTermRetentionVaultsClient struct { + BaseClient +} + +// NewBackupLongTermRetentionVaultsClient creates an instance of the BackupLongTermRetentionVaultsClient client. +func NewBackupLongTermRetentionVaultsClient(subscriptionID string) BackupLongTermRetentionVaultsClient { + return NewBackupLongTermRetentionVaultsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupLongTermRetentionVaultsClientWithBaseURI creates an instance of the BackupLongTermRetentionVaultsClient +// client. +func NewBackupLongTermRetentionVaultsClientWithBaseURI(baseURI string, subscriptionID string) BackupLongTermRetentionVaultsClient { + return BackupLongTermRetentionVaultsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a server backup long term retention vault +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the required +// parameters to update a backup long term retention vault +func (client BackupLongTermRetentionVaultsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters BackupLongTermRetentionVault) (result BackupLongTermRetentionVaultsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionVaultProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.BackupLongTermRetentionVaultProperties.RecoveryServicesVaultResourceID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.BackupLongTermRetentionVaultsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupLongTermRetentionVaultsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters BackupLongTermRetentionVault) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionVaultName": autorest.Encode("path", "RegisteredVault"), + "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}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}", 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 BackupLongTermRetentionVaultsClient) CreateOrUpdateSender(req *http.Request) (future BackupLongTermRetentionVaultsCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionVaultsClient) CreateOrUpdateResponder(resp *http.Response) (result BackupLongTermRetentionVault, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server backup long term retention vault +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client BackupLongTermRetentionVaultsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result BackupLongTermRetentionVault, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "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.BackupLongTermRetentionVaultsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupLongTermRetentionVaultsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupLongTermRetentionVaultName": autorest.Encode("path", "RegisteredVault"), + "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}/backupLongTermRetentionVaults/{backupLongTermRetentionVaultName}", 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 BackupLongTermRetentionVaultsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionVaultsClient) GetResponder(resp *http.Response) (result BackupLongTermRetentionVault, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets server backup long term retention vaults in a server +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client BackupLongTermRetentionVaultsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result BackupLongTermRetentionVaultListResult, err error) { + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "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.BackupLongTermRetentionVaultsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client BackupLongTermRetentionVaultsClient) 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}/backupLongTermRetentionVaults", 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 BackupLongTermRetentionVaultsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client BackupLongTermRetentionVaultsClient) ListByServerResponder(resp *http.Response) (result BackupLongTermRetentionVaultListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/capabilities.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/capabilities.go new file mode 100644 index 000000000000..a62a5970a695 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/capabilities.go @@ -0,0 +1,107 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the capabilities available for the specified location. +// +// locationID is the location id whose capabilities are retrieved. +func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationID string) (result LocationCapabilities, err error) { + req, err := client.ListByLocationPreparer(ctx, locationID) + 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 +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationId": autorest.Encode("path", locationID), + "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}/providers/Microsoft.Sql/locations/{locationId}/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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/client.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/client.go new file mode 100644 index 000000000000..40ec57b36bab --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/client.go @@ -0,0 +1,52 @@ +// 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 and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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. +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-03-01-preview/sql/databaseautomatictuning.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseautomatictuning.go new file mode 100644 index 000000000000..637e96d4ec72 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseautomatictuning.go @@ -0,0 +1,182 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// DatabaseAutomaticTuningClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type DatabaseAutomaticTuningClient struct { + BaseClient +} + +// NewDatabaseAutomaticTuningClient creates an instance of the DatabaseAutomaticTuningClient client. +func NewDatabaseAutomaticTuningClient(subscriptionID string) DatabaseAutomaticTuningClient { + return NewDatabaseAutomaticTuningClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAutomaticTuningClientWithBaseURI creates an instance of the DatabaseAutomaticTuningClient client. +func NewDatabaseAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAutomaticTuningClient { + return DatabaseAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database's automatic tuning. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabaseAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAutomaticTuning, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAutomaticTuningClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAutomaticTuningClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAutomaticTuningClient) GetResponder(resp *http.Response) (result DatabaseAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning properties for target database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the requested automatic tuning resource state. +func (client DatabaseAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAutomaticTuning) (result DatabaseAutomaticTuning, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseAutomaticTuningClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAutomaticTuning) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseAutomaticTuningClient) UpdateResponder(resp *http.Response) (result DatabaseAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseblobauditingpolicies.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseblobauditingpolicies.go new file mode 100644 index 000000000000..8770fc0e82a9 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseblobauditingpolicies.go @@ -0,0 +1,186 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return DatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's blob auditing policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the blob auditing policy will be defined. parameters is the database blob auditing +// policy. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (result DatabaseBlobAuditingPolicy, err error) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's blob auditing policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the blob audit policy is defined. +func (client DatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseoperations.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseoperations.go new file mode 100644 index 000000000000..dfae622d34bd --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseoperations.go @@ -0,0 +1,209 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/satori/go.uuid" + "net/http" +) + +// 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. +func NewDatabaseOperationsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseOperationsClient { + return DatabaseOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. operationID is the operation identifier. +func (client DatabaseOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) { + 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 +} + +// 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-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}/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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase gets a list of operations performed on the database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabaseOperationsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultPage, err error) { + 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 +} + +// 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-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}/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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults DatabaseOperationListResult) (result DatabaseOperationListResult, err error) { + req, err := lastResults.databaseOperationListResultPreparer() + 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) { + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/databases.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/databases.go new file mode 100644 index 000000000000..27ea19bd565a --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/databases.go @@ -0,0 +1,1282 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to import into parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be operated on (updated or created). parameters is 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) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be deleted. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Export exports a database to a bacpac. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be exported. parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be retrieved. expand is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool to be retrieved. databaseName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByRecommendedElasticPool gets a database inside of a recommented elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. recommendedElasticPoolName +// is the name of the elastic pool to be retrieved. databaseName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Import imports a bacpac into a new database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRecommendedElasticPool returns a list of databases inside a recommented elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. recommendedElasticPoolName +// is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. expand is a comma separated +// list of child objects to expand in the response. Possible properties: serviceTierAdvisors, +// transparentDataEncryption. filter is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions returns database metric definitions. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabasesClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result MetricDefinitionListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns database metrics. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. filter is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Pause pauses a data warehouse. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the data warehouse to pause. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Rename renames a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to rename. parameters is 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 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 +} + +// 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-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}/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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a data warehouse. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the data warehouse to resume. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be updated. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/databasethreatdetectionpolicies.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/databasethreatdetectionpolicies.go new file mode 100644 index 000000000000..fdb9dee3f2c9 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/databasethreatdetectionpolicies.go @@ -0,0 +1,186 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDatabaseThreatDetectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseThreatDetectionPoliciesClient { + return DatabaseThreatDetectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's threat detection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which database Threat Detection policy is defined. parameters is the database Threat Detection +// policy. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (result DatabaseSecurityAlertPolicy, err error) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's threat detection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseThreatDetectionPoliciesClient) GetResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseusages.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseusages.go new file mode 100644 index 000000000000..2d531bfa202a --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/databaseusages.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDatabaseUsagesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseUsagesClient { + return DatabaseUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase returns database usages. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabaseUsagesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/datamaskingpolicies.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/datamaskingpolicies.go new file mode 100644 index 000000000000..d462b4be078f --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/datamaskingpolicies.go @@ -0,0 +1,184 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewDataMaskingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingPoliciesClient { + return DataMaskingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking policy +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is 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) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database data masking policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DataMaskingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) GetResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/datamaskingrules.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/datamaskingrules.go new file mode 100644 index 000000000000..5eb74d5df714 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/datamaskingrules.go @@ -0,0 +1,197 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewDataMaskingRulesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingRulesClient { + return DataMaskingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. dataMaskingRuleName is the name of the data masking rule. parameters is 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 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database data masking rules. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DataMaskingRulesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingRuleListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/datawarehouseuseractivities.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/datawarehouseuseractivities.go new file mode 100644 index 000000000000..7f707f560bd4 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/datawarehouseuseractivities.go @@ -0,0 +1,112 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// DataWarehouseUserActivitiesClient 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 DataWarehouseUserActivitiesClient struct { + BaseClient +} + +// NewDataWarehouseUserActivitiesClient creates an instance of the DataWarehouseUserActivitiesClient client. +func NewDataWarehouseUserActivitiesClient(subscriptionID string) DataWarehouseUserActivitiesClient { + return NewDataWarehouseUserActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataWarehouseUserActivitiesClientWithBaseURI creates an instance of the DataWarehouseUserActivitiesClient client. +func NewDataWarehouseUserActivitiesClientWithBaseURI(baseURI string, subscriptionID string) DataWarehouseUserActivitiesClient { + return DataWarehouseUserActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the user activities of a data warehouse which includes running and suspended queries +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DataWarehouseUserActivitiesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataWarehouseUserActivities, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "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.DataWarehouseUserActivitiesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataWarehouseUserActivitiesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataWarehouseUserActivityName": autorest.Encode("path", "current"), + "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}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}", 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 DataWarehouseUserActivitiesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataWarehouseUserActivitiesClient) GetResponder(resp *http.Response) (result DataWarehouseUserActivities, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpoolactivities.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpoolactivities.go new file mode 100644 index 000000000000..207c81fcc0b2 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpoolactivities.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewElasticPoolActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolActivitiesClient { + return ElasticPoolActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns elastic pool activities. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpooldatabaseactivities.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpooldatabaseactivities.go new file mode 100644 index 000000000000..ce30d93c6839 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpooldatabaseactivities.go @@ -0,0 +1,112 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewElasticPoolDatabaseActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return ElasticPoolDatabaseActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns activity on databases inside of an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolDatabaseActivityListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpools.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpools.go new file mode 100644 index 000000000000..c56f6a3e5738 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/elasticpools.go @@ -0,0 +1,532 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new elastic pool or updates an existing elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool to be operated on (updated or created). parameters is 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) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of elastic pools in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ElasticPoolListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions returns elastic pool metric definitions. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client ElasticPoolsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result MetricDefinitionListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns elastic pool metrics. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. filter is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool to be updated. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/encryptionprotectors.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/encryptionprotectors.go new file mode 100644 index 000000000000..6f96e37ce1fc --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/encryptionprotectors.go @@ -0,0 +1,278 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) EncryptionProtectorsClient { + return EncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// encryption protector resource state. +func (client EncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (result EncryptionProtectorsCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server encryption protector. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client EncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtector, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) GetResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server encryption protectors +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client EncryptionProtectorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) ListByServerResponder(resp *http.Response) (result EncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client EncryptionProtectorsClient) listByServerNextResults(lastResults EncryptionProtectorListResult) (result EncryptionProtectorListResult, err error) { + req, err := lastResults.encryptionProtectorListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/failovergroups.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/failovergroups.go new file mode 100644 index 000000000000..06b0ae818b14 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/failovergroups.go @@ -0,0 +1,576 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) FailoverGroupsClient { + return FailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. parameters is the failover group parameters. +func (client FailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (result FailoverGroupsCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary server to this server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsFailoverFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. +func (client FailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroup, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) GetResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the failover groups in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. +func (client FailoverGroupsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ListByServerResponder(resp *http.Response) (result FailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FailoverGroupsClient) listByServerNextResults(lastResults FailoverGroupListResult) (result FailoverGroupListResult, err error) { + req, err := lastResults.failoverGroupListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server containing the failover +// group. failoverGroupName is the name of the failover group. parameters is the failover group parameters. +func (client FailoverGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (result FailoverGroupsUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) UpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/firewallrules.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/firewallrules.go new file mode 100644 index 000000000000..39889599b694 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/firewallrules.go @@ -0,0 +1,327 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. firewallRuleName is the name +// of the firewall rule. parameters is 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 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. firewallRuleName is the name +// of the firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a firewall rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. firewallRuleName is the name +// of the firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of firewall rules. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/geobackuppolicies.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/geobackuppolicies.go new file mode 100644 index 000000000000..fc98307265c5 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/geobackuppolicies.go @@ -0,0 +1,260 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewGeoBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) GeoBackupPoliciesClient { + return GeoBackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database geo backup policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the 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 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a geo backup policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client GeoBackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) GetResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a list of geo backup policies. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client GeoBackupPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicyListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/manageddatabases.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/manageddatabases.go new file mode 100644 index 000000000000..7288a7caa861 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/manageddatabases.go @@ -0,0 +1,501 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/go.uuid" + "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. +func NewManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabasesClient { + return ManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CompleteRestore completes the restore operation on a managed database. +// +// locationName is the name of the region where the resource is located. operationID is management operation id +// that this request tries to complete. parameters is the definition for completing the restore of this managed +// database. +func (client ManagedDatabasesClient) CompleteRestore(ctx context.Context, locationName string, operationID uuid.UUID, parameters CompleteDatabaseRestoreDefinition) (result ManagedDatabasesCompleteRestoreFuture, err error) { + 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, locationName, operationID, 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, locationName string, operationID uuid.UUID, parameters CompleteDatabaseRestoreDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "operationId": autorest.Encode("path", operationID), + "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}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseRestoreAzureAsyncOperation/{operationId}/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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates a new database or updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. parameters is the requested database resource state. +func (client ManagedDatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase) (result ManagedDatabasesCreateOrUpdateFuture, err error) { + 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 = "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}", 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. +func (client ManagedDatabasesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabasesDeleteFuture, err error) { + 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 = "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}/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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. +func (client ManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabase, err error) { + 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 +} + +// 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 = "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}", 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) GetResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed databases. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultPage, err error) { + 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 +} + +// 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 = "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", 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedDatabaseListResult) (result ManagedDatabaseListResult, err error) { + req, err := lastResults.managedDatabaseListResultPreparer() + 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) { + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Update updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. parameters is the requested database resource state. +func (client ManagedDatabasesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseUpdate) (result ManagedDatabasesUpdateFuture, err error) { + 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 = "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}", 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) UpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/managedinstances.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/managedinstances.go new file mode 100644 index 000000000000..816c0028db69 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/managedinstances.go @@ -0,0 +1,513 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstance, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go new file mode 100644 index 000000000000..7328036c059d --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/models.go @@ -0,0 +1,11706 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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/satori/go.uuid" + "net/http" +) + +// 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} +} + +// 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} +} + +// BackupLongTermRetentionPolicyState enumerates the values for backup long term retention policy state. +type BackupLongTermRetentionPolicyState string + +const ( + // BackupLongTermRetentionPolicyStateDisabled ... + BackupLongTermRetentionPolicyStateDisabled BackupLongTermRetentionPolicyState = "Disabled" + // BackupLongTermRetentionPolicyStateEnabled ... + BackupLongTermRetentionPolicyStateEnabled BackupLongTermRetentionPolicyState = "Enabled" +) + +// PossibleBackupLongTermRetentionPolicyStateValues returns an array of possible values for the BackupLongTermRetentionPolicyState const type. +func PossibleBackupLongTermRetentionPolicyStateValues() []BackupLongTermRetentionPolicyState { + return []BackupLongTermRetentionPolicyState{BackupLongTermRetentionPolicyStateDisabled, BackupLongTermRetentionPolicyStateEnabled} +} + +// 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} +} + +// 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" + // CreateModeNonReadableSecondary ... + CreateModeNonReadableSecondary CreateMode = "NonReadableSecondary" + // CreateModeOnlineSecondary ... + CreateModeOnlineSecondary CreateMode = "OnlineSecondary" + // CreateModePointInTimeRestore ... + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeRecovery ... + CreateModeRecovery CreateMode = "Recovery" + // CreateModeRestore ... + CreateModeRestore CreateMode = "Restore" + // CreateModeRestoreLongTermRetentionBackup ... + CreateModeRestoreLongTermRetentionBackup CreateMode = "RestoreLongTermRetentionBackup" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeCopy, CreateModeDefault, CreateModeNonReadableSecondary, CreateModeOnlineSecondary, CreateModePointInTimeRestore, CreateModeRecovery, CreateModeRestore, CreateModeRestoreLongTermRetentionBackup} +} + +// DatabaseEdition enumerates the values for database edition. +type DatabaseEdition string + +const ( + // Basic ... + Basic DatabaseEdition = "Basic" + // Business ... + Business DatabaseEdition = "Business" + // DataWarehouse ... + DataWarehouse DatabaseEdition = "DataWarehouse" + // Free ... + Free DatabaseEdition = "Free" + // 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, DataWarehouse, Free, 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" + // 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, 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 ( + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{SystemAssigned} +} + +// ManagedDatabaseCreateMode enumerates the values for managed database create mode. +type ManagedDatabaseCreateMode string + +const ( + // ManagedDatabaseCreateModeDefault ... + ManagedDatabaseCreateModeDefault ManagedDatabaseCreateMode = "Default" + // ManagedDatabaseCreateModePointInTimeRestore ... + ManagedDatabaseCreateModePointInTimeRestore ManagedDatabaseCreateMode = "PointInTimeRestore" + // ManagedDatabaseCreateModeRestoreExternalBackup ... + ManagedDatabaseCreateModeRestoreExternalBackup ManagedDatabaseCreateMode = "RestoreExternalBackup" +) + +// PossibleManagedDatabaseCreateModeValues returns an array of possible values for the ManagedDatabaseCreateMode const type. +func PossibleManagedDatabaseCreateModeValues() []ManagedDatabaseCreateMode { + return []ManagedDatabaseCreateMode{ManagedDatabaseCreateModeDefault, ManagedDatabaseCreateModePointInTimeRestore, ManagedDatabaseCreateModeRestoreExternalBackup} +} + +// 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" + // Shutdown ... + Shutdown ManagedDatabaseStatus = "Shutdown" +) + +// PossibleManagedDatabaseStatusValues returns an array of possible values for the ManagedDatabaseStatus const type. +func PossibleManagedDatabaseStatusValues() []ManagedDatabaseStatus { + return []ManagedDatabaseStatus{Creating, Inaccessible, Offline, Online, Shutdown} +} + +// 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} +} + +// 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 ( + // Average ... + Average PrimaryAggregationType = "Average" + // Count ... + Count PrimaryAggregationType = "Count" + // Maximum ... + Maximum PrimaryAggregationType = "Maximum" + // Minimum ... + Minimum PrimaryAggregationType = "Minimum" + // None ... + None PrimaryAggregationType = "None" + // Total ... + Total 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} +} + +// 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 ( + // 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} +} + +// 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 ( + // 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 ( + // All ... + All SyncGroupLogType = "All" + // Error ... + Error SyncGroupLogType = "Error" + // Success ... + Success SyncGroupLogType = "Success" + // Warning ... + Warning SyncGroupLogType = "Warning" +) + +// PossibleSyncGroupLogTypeValues returns an array of possible values for the SyncGroupLogType const type. +func PossibleSyncGroupLogTypeValues() []SyncGroupLogType { + return []SyncGroupLogType{All, Error, Success, Warning} +} + +// SyncGroupState enumerates the values for sync group state. +type SyncGroupState string + +const ( + // SyncGroupStateError ... + SyncGroupStateError SyncGroupState = "Error" + // SyncGroupStateGood ... + SyncGroupStateGood SyncGroupState = "Good" + // SyncGroupStateNotReady ... + SyncGroupStateNotReady SyncGroupState = "NotReady" + // SyncGroupStateProgressing ... + SyncGroupStateProgressing SyncGroupState = "Progressing" + // SyncGroupStateWarning ... + SyncGroupStateWarning SyncGroupState = "Warning" +) + +// PossibleSyncGroupStateValues returns an array of possible values for the SyncGroupState const type. +func PossibleSyncGroupStateValues() []SyncGroupState { + return []SyncGroupState{SyncGroupStateError, SyncGroupStateGood, SyncGroupStateNotReady, SyncGroupStateProgressing, SyncGroupStateWarning} +} + +// 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} +} + +// AutomaticTuningOptions automatic tuning properties for individual advisors. +type AutomaticTuningOptions struct { + // DesiredState - Automatic tuning option desired state. Possible values include: 'AutomaticTuningOptionModeDesiredOff', 'AutomaticTuningOptionModeDesiredOn', 'AutomaticTuningOptionModeDesiredDefault' + DesiredState AutomaticTuningOptionModeDesired `json:"desiredState,omitempty"` + // ActualState - Automatic tuning option actual state. Possible values include: 'Off', 'On' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - Reason description if desired and actual state are different. Possible values include: 'Default', 'Disabled', 'AutoConfigured', 'InheritedFromServer', 'QueryStoreOff', 'QueryStoreReadOnly', 'NotSupported' + ReasonDesc AutomaticTuningDisabledReason `json:"reasonDesc,omitempty"` +} + +// AutomaticTuningServerOptions automatic tuning properties for individual advisors. +type AutomaticTuningServerOptions struct { + // DesiredState - Automatic tuning option desired state. Possible values include: 'AutomaticTuningOptionModeDesiredOff', 'AutomaticTuningOptionModeDesiredOn', 'AutomaticTuningOptionModeDesiredDefault' + DesiredState AutomaticTuningOptionModeDesired `json:"desiredState,omitempty"` + // ActualState - Automatic tuning option actual state. Possible values include: 'Off', 'On' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - Reason description if desired and actual state are different. Possible values include: 'AutomaticTuningServerReasonDefault', 'AutomaticTuningServerReasonDisabled', 'AutomaticTuningServerReasonAutoConfigured' + ReasonDesc AutomaticTuningServerReason `json:"reasonDesc,omitempty"` +} + +// AutomaticTuningServerProperties server-level Automatic Tuning properties. +type AutomaticTuningServerProperties struct { + // DesiredState - Automatic tuning desired state. Possible values include: 'AutomaticTuningServerModeCustom', 'AutomaticTuningServerModeAuto', 'AutomaticTuningServerModeUnspecified' + DesiredState AutomaticTuningServerMode `json:"desiredState,omitempty"` + // ActualState - Automatic tuning actual state. Possible values include: 'AutomaticTuningServerModeCustom', 'AutomaticTuningServerModeAuto', 'AutomaticTuningServerModeUnspecified' + ActualState AutomaticTuningServerMode `json:"actualState,omitempty"` + // Options - Automatic tuning options definition. + Options map[string]*AutomaticTuningServerOptions `json:"options"` +} + +// 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.ActualState != "" { + objectMap["actualState"] = atsp.ActualState + } + if atsp.Options != nil { + objectMap["options"] = atsp.Options + } + return json.Marshal(objectMap) +} + +// BackupLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type BackupLongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future BackupLongTermRetentionPoliciesCreateOrUpdateFuture) Result(client BackupLongTermRetentionPoliciesClient) (bltrp BackupLongTermRetentionPolicy, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return bltrp, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + bltrp, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + bltrp, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// BackupLongTermRetentionPolicy a backup long term retention policy +type BackupLongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // BackupLongTermRetentionPolicyProperties - The properties of the backup long term retention policy + *BackupLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = bltrp.Location + } + if bltrp.BackupLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = bltrp.BackupLongTermRetentionPolicyProperties + } + if bltrp.ID != nil { + objectMap["id"] = bltrp.ID + } + if bltrp.Name != nil { + objectMap["name"] = bltrp.Name + } + if bltrp.Type != nil { + objectMap["type"] = bltrp.Type + } + 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 "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + bltrp.Location = &location + } + case "properties": + if v != nil { + var backupLongTermRetentionPolicyProperties BackupLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &backupLongTermRetentionPolicyProperties) + if err != nil { + return err + } + bltrp.BackupLongTermRetentionPolicyProperties = &backupLongTermRetentionPolicyProperties + } + 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 +} + +// BackupLongTermRetentionPolicyListResult represents the response to a list long-term retention policies request. +type BackupLongTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - The list of long-term retention policies in the database. + Value *[]BackupLongTermRetentionPolicy `json:"value,omitempty"` +} + +// BackupLongTermRetentionPolicyProperties the properties of a backup long term retention policy +type BackupLongTermRetentionPolicyProperties struct { + // State - The status of the backup long term retention policy. Possible values include: 'BackupLongTermRetentionPolicyStateDisabled', 'BackupLongTermRetentionPolicyStateEnabled' + State BackupLongTermRetentionPolicyState `json:"state,omitempty"` + // RecoveryServicesBackupPolicyResourceID - The azure recovery services backup protection policy resource id + RecoveryServicesBackupPolicyResourceID *string `json:"recoveryServicesBackupPolicyResourceId,omitempty"` +} + +// BackupLongTermRetentionVault a backup long term retention vault +type BackupLongTermRetentionVault struct { + autorest.Response `json:"-"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // BackupLongTermRetentionVaultProperties - The properties of the backup long term retention vault + *BackupLongTermRetentionVaultProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupLongTermRetentionVault. +func (bltrv BackupLongTermRetentionVault) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bltrv.Location != nil { + objectMap["location"] = bltrv.Location + } + if bltrv.BackupLongTermRetentionVaultProperties != nil { + objectMap["properties"] = bltrv.BackupLongTermRetentionVaultProperties + } + if bltrv.ID != nil { + objectMap["id"] = bltrv.ID + } + if bltrv.Name != nil { + objectMap["name"] = bltrv.Name + } + if bltrv.Type != nil { + objectMap["type"] = bltrv.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupLongTermRetentionVault struct. +func (bltrv *BackupLongTermRetentionVault) 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 + } + bltrv.Location = &location + } + case "properties": + if v != nil { + var backupLongTermRetentionVaultProperties BackupLongTermRetentionVaultProperties + err = json.Unmarshal(*v, &backupLongTermRetentionVaultProperties) + if err != nil { + return err + } + bltrv.BackupLongTermRetentionVaultProperties = &backupLongTermRetentionVaultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bltrv.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bltrv.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bltrv.Type = &typeVar + } + } + } + + return nil +} + +// BackupLongTermRetentionVaultListResult represents the response to a list vaults request. +type BackupLongTermRetentionVaultListResult struct { + autorest.Response `json:"-"` + // Value - The list of vaults in the server. + Value *[]BackupLongTermRetentionVault `json:"value,omitempty"` +} + +// BackupLongTermRetentionVaultProperties the properties of a backup long term retention vault. +type BackupLongTermRetentionVaultProperties struct { + // RecoveryServicesVaultResourceID - The azure recovery services vault resource id + RecoveryServicesVaultResourceID *string `json:"recoveryServicesVaultResourceId,omitempty"` +} + +// BackupLongTermRetentionVaultsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type BackupLongTermRetentionVaultsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future BackupLongTermRetentionVaultsCreateOrUpdateFuture) Result(client BackupLongTermRetentionVaultsClient) (bltrv BackupLongTermRetentionVault, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return bltrv, azure.NewAsyncOpIncompleteError("sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + bltrv, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + bltrv, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupLongTermRetentionVaultsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - True if the name is available, otherwise false. + Available *bool `json:"available,omitempty"` + // Message - A message explaining why the name is unavailable. Will be null if the name is available. + Message *string `json:"message,omitempty"` + // Name - The name whose availability was checked. + Name *string `json:"name,omitempty"` + // Reason - 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"` +} + +// 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 represents a database. +type Database struct { + autorest.Response `json:"-"` + // Kind - 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"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = d.Kind + } + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Type != nil { + objectMap["type"] = d.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if dat.ID != nil { + objectMap["id"] = dat.ID + } + if dat.Name != nil { + objectMap["name"] = dat.Name + } + if dat.Type != nil { + objectMap["type"] = dat.Type + } + 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 - 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.ActualState != "" { + objectMap["actualState"] = datp.ActualState + } + 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 - Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseBlobAuditingPolicyProperties - Resource properties. + *DatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = dbap.Kind + } + if dbap.DatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = dbap.DatabaseBlobAuditingPolicyProperties + } + if dbap.ID != nil { + objectMap["id"] = dbap.ID + } + if dbap.Name != nil { + objectMap["name"] = dbap.Name + } + if dbap.Type != nil { + objectMap["type"] = dbap.Type + } + 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 +} + +// DatabaseBlobAuditingPolicyProperties properties of a database blob auditing policy. +type DatabaseBlobAuditingPolicyProperties struct { + // State - Specifies the state of the policy. If state is Enabled, storageEndpoint and storageAccountAccessKey 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 is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. If state is Enabled, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions and Actions-Groups to audit. + 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"` +} + +// 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"` +} + +// DatabaseOperation a database operation. +type DatabaseOperation struct { + // DatabaseOperationProperties - Resource properties. + *DatabaseOperationProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if do.ID != nil { + objectMap["id"] = do.ID + } + if do.Name != nil { + objectMap["name"] = do.Name + } + if do.Type != nil { + objectMap["type"] = do.Type + } + 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 - Array of results. + Value *[]DatabaseOperation `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DatabaseOperationListResultIterator provides access to a complete listing of DatabaseOperation values. +type DatabaseOperationListResultIterator struct { + i int + page DatabaseOperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseOperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dolr DatabaseOperationListResult) IsEmpty() bool { + return dolr.Value == nil || len(*dolr.Value) == 0 +} + +// databaseOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dolr DatabaseOperationListResult) databaseOperationListResultPreparer() (*http.Request, error) { + if dolr.NextLink == nil || len(to.String(dolr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dolr.NextLink))) +} + +// DatabaseOperationListResultPage contains a page of DatabaseOperation values. +type DatabaseOperationListResultPage struct { + fn func(DatabaseOperationListResult) (DatabaseOperationListResult, error) + dolr DatabaseOperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseOperationListResultPage) Next() error { + next, err := page.fn(page.dolr) + if err != nil { + return err + } + page.dolr = next + return nil +} + +// 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 +} + +// DatabaseOperationProperties the properties of a database operation. +type DatabaseOperationProperties struct { + // DatabaseName - The name of the database the operation is being performed on. + DatabaseName *string `json:"databaseName,omitempty"` + // Operation - The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - The operation state. Possible values include: 'Pending', 'InProgress', 'Succeeded', 'Failed', 'CancelInProgress', 'Cancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,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 - The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // ContainmentState - The containment state of the database. + ContainmentState *int64 `json:"containmentState,omitempty"` + // CurrentServiceObjectiveID - 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 - The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // EarliestRestoreDate - 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: 'CreateModeCopy', 'CreateModeDefault', 'CreateModeNonReadableSecondary', 'CreateModeOnlineSecondary', 'CreateModePointInTimeRestore', 'CreateModeRecovery', 'CreateModeRestore', 'CreateModeRestoreLongTermRetentionBackup' + CreateMode CreateMode `json:"createMode,omitempty"` + // SourceDatabaseID - Conditional. If createMode is Copy, NonReadableSecondary, OnlineSecondary, PointInTimeRestore, Recovery, or Restore, then this value is required. Specifies the resource ID of the source database. If createMode is NonReadableSecondary or OnlineSecondary, the name of the source database must be the same as the new database being created. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // 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. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." or use the Azure CLI command `az sql db list-editions -l westus --query [].name`. Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2' + 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. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." or use the Azure CLI command `az sql db list-editions --location --query [].supportedServiceLevelObjectives[].name` . + 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. To see possible values, query the capabilities API (/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationID}/capabilities) referred to by operationId: "Capabilities_ListByLocation." or use the Azure CLI command `az sql db list-editions --location --query [].supportedServiceLevelObjectives[].name`. 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 - 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 - 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 - The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // ServiceTierAdvisors - The list of service tier advisors for this database. Expanded property + ServiceTierAdvisors *[]ServiceTierAdvisor `json:"serviceTierAdvisors,omitempty"` + // TransparentDataEncryption - The transparent data encryption info for this database. + TransparentDataEncryption *[]TransparentDataEncryption `json:"transparentDataEncryption,omitempty"` + // RecommendedIndex - The recommended indices for this database. + RecommendedIndex *[]RecommendedIndex `json:"recommendedIndex,omitempty"` + // FailoverGroupID - 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"` +} + +// DatabasesCreateImportOperationFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateImportOperationFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesCreateImportOperationFuture) Result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateImportOperationFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ier, err = client.CreateImportOperationResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure sending request") + return + } + ier, err = client.CreateImportOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateImportOperationFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseSecurityAlertPolicyProperties - Properties of the security alert policy. + *DatabaseSecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = dsap.Kind + } + if dsap.DatabaseSecurityAlertPolicyProperties != nil { + objectMap["properties"] = dsap.DatabaseSecurityAlertPolicyProperties + } + if dsap.ID != nil { + objectMap["id"] = dsap.ID + } + if dsap.Name != nil { + objectMap["name"] = dsap.Name + } + if dsap.Type != nil { + objectMap["type"] = dsap.Type + } + 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; Usage_Anomaly. + 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesExportFuture) Result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ier, err = client.ExportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure sending request") + return + } + ier, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesImportFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesImportFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesImportFuture) Result(client DatabasesClient) (ier ImportExportResponse, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ier, azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ier, err = client.ImportResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure sending request") + return + } + ier, err = client.ImportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesPauseFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesPauseFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.PauseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesResumeFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesResumeFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.ResumeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if du.ID != nil { + objectMap["id"] = du.ID + } + if du.Name != nil { + objectMap["name"] = du.Name + } + if du.Type != nil { + objectMap["type"] = du.Type + } + 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 - The name of the usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - The usage metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - The current value of the usage metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - The current limit of the usage metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - The units of the usage metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - The next reset time for the usage metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// 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 - The location of the data masking policy. + Location *string `json:"location,omitempty"` + // Kind - The kind of data masking policy. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if dmp.Location != nil { + objectMap["location"] = dmp.Location + } + if dmp.Kind != nil { + objectMap["kind"] = dmp.Kind + } + if dmp.ID != nil { + objectMap["id"] = dmp.ID + } + if dmp.Name != nil { + objectMap["name"] = dmp.Name + } + if dmp.Type != nil { + objectMap["type"] = dmp.Type + } + 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 - The list of the application principals. This is a legacy parameter and is no longer used. + ApplicationPrincipals *string `json:"applicationPrincipals,omitempty"` + // MaskingLevel - The masking level. This is a legacy parameter and is no longer used. + MaskingLevel *string `json:"maskingLevel,omitempty"` +} + +// DataMaskingRule represents a database data masking rule. +type DataMaskingRule struct { + autorest.Response `json:"-"` + // DataMaskingRuleProperties - The properties of the resource. + *DataMaskingRuleProperties `json:"properties,omitempty"` + // Location - The location of the data masking rule. + Location *string `json:"location,omitempty"` + // Kind - The kind of Data Masking Rule. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if dmr.Location != nil { + objectMap["location"] = dmr.Location + } + if dmr.Kind != nil { + objectMap["kind"] = dmr.Kind + } + if dmr.ID != nil { + objectMap["id"] = dmr.ID + } + if dmr.Name != nil { + objectMap["name"] = dmr.Name + } + if dmr.Type != nil { + objectMap["type"] = dmr.Type + } + 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 - 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"` +} + +// DataWarehouseUserActivities user activities of a data warehouse +type DataWarehouseUserActivities struct { + autorest.Response `json:"-"` + // DataWarehouseUserActivitiesProperties - Resource properties. + *DataWarehouseUserActivitiesProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataWarehouseUserActivities. +func (dwua DataWarehouseUserActivities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dwua.DataWarehouseUserActivitiesProperties != nil { + objectMap["properties"] = dwua.DataWarehouseUserActivitiesProperties + } + if dwua.ID != nil { + objectMap["id"] = dwua.ID + } + if dwua.Name != nil { + objectMap["name"] = dwua.Name + } + if dwua.Type != nil { + objectMap["type"] = dwua.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataWarehouseUserActivities struct. +func (dwua *DataWarehouseUserActivities) 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 dataWarehouseUserActivitiesProperties DataWarehouseUserActivitiesProperties + err = json.Unmarshal(*v, &dataWarehouseUserActivitiesProperties) + if err != nil { + return err + } + dwua.DataWarehouseUserActivitiesProperties = &dataWarehouseUserActivitiesProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dwua.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dwua.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dwua.Type = &typeVar + } + } + } + + return nil +} + +// DataWarehouseUserActivitiesProperties user activities of a data warehouse. This currently includes the count of +// running or suspended queries. For more information, please view the sys.dm_pdw_exec_requests dynamic management +// view (DMV). +type DataWarehouseUserActivitiesProperties struct { + // ActiveQueriesCount - Count of running and suspended queries. + ActiveQueriesCount *int32 `json:"activeQueriesCount,omitempty"` +} + +// EditionCapability the database edition capabilities. +type EditionCapability struct { + // Name - The edition name. + Name *string `json:"name,omitempty"` + // Status - The status of the edition. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // SupportedServiceLevelObjectives - The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // ZoneRedundant - Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +// ElasticPool represents a database elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // ElasticPoolProperties - The properties representing the resource. + *ElasticPoolProperties `json:"properties,omitempty"` + // Kind - Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = ep.Kind + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.ID != nil { + objectMap["id"] = ep.ID + } + if ep.Name != nil { + objectMap["name"] = ep.Name + } + if ep.Type != nil { + objectMap["type"] = ep.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epa.ID != nil { + objectMap["id"] = epa.ID + } + if epa.Name != nil { + objectMap["name"] = epa.Name + } + if epa.Type != nil { + objectMap["type"] = epa.Type + } + 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 - The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedDatabaseDtuMax - The requested max DTU per database if available. + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + // RequestedDatabaseDtuMin - The requested min DTU per database if available. + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + // RequestedDtu - The requested DTU for the pool if available. + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + // RequestedElasticPoolName - The requested name for the elastic pool if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // RequestedStorageLimitInGB - The requested storage limit for the pool in GB if available. + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + // ElasticPoolName - The name of the elastic pool. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ServerName - The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - The current state of the operation. + State *string `json:"state,omitempty"` + // RequestedStorageLimitInMB - The requested storage limit in MB. + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + // RequestedDatabaseDtuGuarantee - The requested per database DTU guarantee. + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + // RequestedDatabaseDtuCap - The requested per database DTU cap. + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + // RequestedDtuGuarantee - The requested DTU guarantee. + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epda.ID != nil { + objectMap["id"] = epda.ID + } + if epda.Name != nil { + objectMap["name"] = epda.Name + } + if epda.Type != nil { + objectMap["type"] = epda.Type + } + 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 - The database name. + DatabaseName *string `json:"databaseName,omitempty"` + // EndTime - The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedElasticPoolName - The name for the elastic pool the database is moving into if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // CurrentElasticPoolName - The name of the current elastic pool the database is in if available. + CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` + // CurrentServiceObjective - The name of the current service objective if available. + CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` + // RequestedServiceObjective - The name of the requested service objective if available. + RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` + // ServerName - The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - The current state of the operation. + State *string `json:"state,omitempty"` +} + +// ElasticPoolDtuCapability the Elastic Pool DTU capability. +type ElasticPoolDtuCapability struct { + // Limit - The maximum size of the database (see 'unit' for the units). + Limit *int64 `json:"limit,omitempty"` + // MaxDatabaseCount - The maximum number of databases supported. + MaxDatabaseCount *int64 `json:"maxDatabaseCount,omitempty"` + // Status - The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // SupportedMaxSizes - The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + // IncludedMaxSize - The included (free) max size for this service level objective. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedPerDatabaseMaxSizes - The list of supported max database sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxDtus - The list of supported max database DTUs. + SupportedPerDatabaseMaxDtus *[]ElasticPoolPerDatabaseMaxDtuCapability `json:"supportedPerDatabaseMaxDtus,omitempty"` +} + +// ElasticPoolEditionCapability the elastic pool edition capabilities. +type ElasticPoolEditionCapability struct { + // Name - The elastic pool edition name. + Name *string `json:"name,omitempty"` + // Status - The status of the elastic pool edition. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // SupportedElasticPoolDtus - The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolDtus *[]ElasticPoolDtuCapability `json:"supportedElasticPoolDtus,omitempty"` + // ZoneRedundant - Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +// 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 - The maximum DTUs per database. + Limit *int64 `json:"limit,omitempty"` + // Status - The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // SupportedPerDatabaseMinDtus - The list of supported min database DTUs. + SupportedPerDatabaseMinDtus *[]ElasticPoolPerDatabaseMinDtuCapability `json:"supportedPerDatabaseMinDtus,omitempty"` +} + +// ElasticPoolPerDatabaseMinDtuCapability the minimum per-database DTU capability. +type ElasticPoolPerDatabaseMinDtuCapability struct { + // Limit - The maximum DTUs per database. + Limit *int64 `json:"limit,omitempty"` + // Status - The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` +} + +// ElasticPoolProperties represents the properties of an elastic pool. +type ElasticPoolProperties struct { + // CreationDate - The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // State - 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' + 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"` +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsCreateOrUpdateFuture) Result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ElasticPoolsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsUpdateFuture) Result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epu.ID != nil { + objectMap["id"] = epu.ID + } + if epu.Name != nil { + objectMap["name"] = epu.Name + } + if epu.Type != nil { + objectMap["type"] = epu.Type + } + 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 - Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // EncryptionProtectorProperties - Resource properties. + *EncryptionProtectorProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = ep.Kind + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.EncryptionProtectorProperties != nil { + objectMap["properties"] = ep.EncryptionProtectorProperties + } + if ep.ID != nil { + objectMap["id"] = ep.ID + } + if ep.Name != nil { + objectMap["name"] = ep.Name + } + if ep.Type != nil { + objectMap["type"] = ep.Type + } + 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 - Array of results. + Value *[]EncryptionProtector `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector values. +type EncryptionProtectorListResultIterator struct { + i int + page EncryptionProtectorListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EncryptionProtectorListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr EncryptionProtectorListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer() (*http.Request, error) { + if eplr.NextLink == nil || len(to.String(eplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. +type EncryptionProtectorListResultPage struct { + fn func(EncryptionProtectorListResult) (EncryptionProtectorListResult, error) + eplr EncryptionProtectorListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EncryptionProtectorListResultPage) Next() error { + next, err := page.fn(page.eplr) + if err != nil { + return err + } + page.eplr = next + return nil +} + +// 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 +} + +// EncryptionProtectorProperties properties for an encryption protector execution. +type EncryptionProtectorProperties struct { + // Subregion - 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 - The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future EncryptionProtectorsCreateOrUpdateFuture) Result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // FailoverGroupProperties - Resource properties. + *FailoverGroupProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = fg.Location + } + if fg.Tags != nil { + objectMap["tags"] = fg.Tags + } + if fg.FailoverGroupProperties != nil { + objectMap["properties"] = fg.FailoverGroupProperties + } + if fg.ID != nil { + objectMap["id"] = fg.ID + } + if fg.Name != nil { + objectMap["name"] = fg.Name + } + if fg.Type != nil { + objectMap["type"] = fg.Type + } + 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 - Array of results. + Value *[]FailoverGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. +type FailoverGroupListResultIterator struct { + i int + page FailoverGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *FailoverGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (fglr FailoverGroupListResult) IsEmpty() bool { + return fglr.Value == nil || len(*fglr.Value) == 0 +} + +// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (fglr FailoverGroupListResult) failoverGroupListResultPreparer() (*http.Request, error) { + if fglr.NextLink == nil || len(to.String(fglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(fglr.NextLink))) +} + +// FailoverGroupListResultPage contains a page of FailoverGroup values. +type FailoverGroupListResultPage struct { + fn func(FailoverGroupListResult) (FailoverGroupListResult, error) + fglr FailoverGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *FailoverGroupListResultPage) Next() error { + next, err := page.fn(page.fglr) + if err != nil { + return err + } + page.fglr = next + return nil +} + +// 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 +} + +// 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 - Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - 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"` +} + +// 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsCreateOrUpdateFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type FailoverGroupsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsDeleteFuture) Result(client FailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsFailoverFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsFailoverFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsForceFailoverAllowDataLossFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.ForceFailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.ForceFailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } + return +} + +// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type FailoverGroupsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future FailoverGroupsUpdateFuture) Result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return fg, azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + fg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure sending request") + return + } + fg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Kind of server that contains this firewall rule. + Kind *string `json:"kind,omitempty"` + // Location - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = fr.Kind + } + if fr.Location != nil { + objectMap["location"] = fr.Location + } + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + if fr.ID != nil { + objectMap["id"] = fr.ID + } + if fr.Name != nil { + objectMap["name"] = fr.Name + } + if fr.Type != nil { + objectMap["type"] = fr.Type + } + 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 - Kind of geo backup policy. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Backup policy location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if gbp.Kind != nil { + objectMap["kind"] = gbp.Kind + } + if gbp.Location != nil { + objectMap["location"] = gbp.Location + } + if gbp.ID != nil { + objectMap["id"] = gbp.ID + } + if gbp.Name != nil { + objectMap["name"] = gbp.Name + } + if gbp.Type != nil { + objectMap["type"] = gbp.Type + } + 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 - The storage type of the geo backup policy. + StorageType *string `json:"storageType,omitempty"` +} + +// ImportExportResponse response for Import/Export Get operation. +type ImportExportResponse struct { + autorest.Response `json:"-"` + // ImportExportResponseProperties - The import/export operation properties. + *ImportExportResponseProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if ier.ID != nil { + objectMap["id"] = ier.ID + } + if ier.Name != nil { + objectMap["name"] = ier.Name + } + if ier.Type != nil { + objectMap["type"] = ier.Type + } + 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 - The request type of the operation. + RequestType *string `json:"requestType,omitempty"` + // RequestID - The request type of the operation. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // ServerName - The name of the server. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The name of the database. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - The status message returned from the server. + Status *string `json:"status,omitempty"` + // LastModifiedTime - The operation status last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // QueuedTime - The operation queued time. + QueuedTime *string `json:"queuedTime,omitempty"` + // BlobURI - The blob uri. + BlobURI *string `json:"blobUri,omitempty"` + // ErrorMessage - The error message returned from the server. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// 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. Possible values include: 'Web', 'Business', 'Basic', 'Standard', 'Premium', 'PremiumRS', 'Free', 'Stretch', 'DataWarehouse', 'System', 'System2' + Edition DatabaseEdition `json:"edition,omitempty"` + // ServiceObjectiveName - The name of the service objective to assign to the database. Possible values include: 'ServiceObjectiveNameSystem', 'ServiceObjectiveNameSystem0', 'ServiceObjectiveNameSystem1', 'ServiceObjectiveNameSystem2', 'ServiceObjectiveNameSystem3', 'ServiceObjectiveNameSystem4', 'ServiceObjectiveNameSystem2L', 'ServiceObjectiveNameSystem3L', 'ServiceObjectiveNameSystem4L', 'ServiceObjectiveNameFree', 'ServiceObjectiveNameBasic', 'ServiceObjectiveNameS0', 'ServiceObjectiveNameS1', 'ServiceObjectiveNameS2', 'ServiceObjectiveNameS3', 'ServiceObjectiveNameS4', 'ServiceObjectiveNameS6', 'ServiceObjectiveNameS7', 'ServiceObjectiveNameS9', 'ServiceObjectiveNameS12', 'ServiceObjectiveNameP1', 'ServiceObjectiveNameP2', 'ServiceObjectiveNameP3', 'ServiceObjectiveNameP4', 'ServiceObjectiveNameP6', 'ServiceObjectiveNameP11', 'ServiceObjectiveNameP15', 'ServiceObjectiveNamePRS1', 'ServiceObjectiveNamePRS2', 'ServiceObjectiveNamePRS4', 'ServiceObjectiveNamePRS6', 'ServiceObjectiveNameDW100', 'ServiceObjectiveNameDW200', 'ServiceObjectiveNameDW300', 'ServiceObjectiveNameDW400', 'ServiceObjectiveNameDW500', 'ServiceObjectiveNameDW600', 'ServiceObjectiveNameDW1000', 'ServiceObjectiveNameDW1200', 'ServiceObjectiveNameDW1000c', 'ServiceObjectiveNameDW1500', 'ServiceObjectiveNameDW1500c', 'ServiceObjectiveNameDW2000', 'ServiceObjectiveNameDW2000c', 'ServiceObjectiveNameDW3000', 'ServiceObjectiveNameDW2500c', 'ServiceObjectiveNameDW3000c', 'ServiceObjectiveNameDW6000', 'ServiceObjectiveNameDW5000c', 'ServiceObjectiveNameDW6000c', 'ServiceObjectiveNameDW7500c', 'ServiceObjectiveNameDW10000c', 'ServiceObjectiveNameDW15000c', 'ServiceObjectiveNameDW30000c', 'ServiceObjectiveNameDS100', 'ServiceObjectiveNameDS200', 'ServiceObjectiveNameDS300', 'ServiceObjectiveNameDS400', 'ServiceObjectiveNameDS500', 'ServiceObjectiveNameDS600', 'ServiceObjectiveNameDS1000', 'ServiceObjectiveNameDS1200', 'ServiceObjectiveNameDS1500', 'ServiceObjectiveNameDS2000', 'ServiceObjectiveNameElasticPool' + ServiceObjectiveName ServiceObjectiveName `json:"serviceObjectiveName,omitempty"` + // MaxSizeBytes - The maximum size for the newly imported database. + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // 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 capabilities for a location. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - The location name. + Name *string `json:"name,omitempty"` + // Status - Azure SQL Database's status for the location. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // SupportedServerVersions - The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` +} + +// ManagedDatabase a managed database resource. +type ManagedDatabase struct { + autorest.Response `json:"-"` + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = md.Tags + } + if md.Location != nil { + objectMap["location"] = md.Location + } + if md.ID != nil { + objectMap["id"] = md.ID + } + if md.Name != nil { + objectMap["name"] = md.Name + } + if md.Type != nil { + objectMap["type"] = md.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + md.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + md.Location = &location + } + 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 - Array of results. + Value *[]ManagedDatabase `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ManagedDatabaseListResultIterator provides access to a complete listing of ManagedDatabase values. +type ManagedDatabaseListResultIterator struct { + i int + page ManagedDatabaseListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedDatabaseListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (mdlr ManagedDatabaseListResult) IsEmpty() bool { + return mdlr.Value == nil || len(*mdlr.Value) == 0 +} + +// managedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mdlr ManagedDatabaseListResult) managedDatabaseListResultPreparer() (*http.Request, error) { + if mdlr.NextLink == nil || len(to.String(mdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mdlr.NextLink))) +} + +// ManagedDatabaseListResultPage contains a page of ManagedDatabase values. +type ManagedDatabaseListResultPage struct { + fn func(ManagedDatabaseListResult) (ManagedDatabaseListResult, error) + mdlr ManagedDatabaseListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedDatabaseListResultPage) Next() error { + next, err := page.fn(page.mdlr) + if err != nil { + return err + } + page.mdlr = next + return nil +} + +// 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 +} + +// ManagedDatabaseProperties the managed database's properties. +type ManagedDatabaseProperties struct { + // Collation - Collation of the managed database. + Collation *string `json:"collation,omitempty"` + // Status - Status for the database. Possible values include: 'Online', 'Offline', 'Shutdown', 'Creating', 'Inaccessible' + Status ManagedDatabaseStatus `json:"status,omitempty"` + // CreationDate - Creation date of the database. + CreationDate *date.Time `json:"creationDate,omitempty"` + // EarliestRestorePoint - 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 - 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. Possible values include: 'ManagedDatabaseCreateModeDefault', 'ManagedDatabaseCreateModeRestoreExternalBackup', 'ManagedDatabaseCreateModePointInTimeRestore' + 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"` + // StorageContainerSasToken - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. + StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` + // FailoverGroupID - Instance Failover Group resource identifier that this managed database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` +} + +// ManagedDatabasesCompleteRestoreFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesCompleteRestoreFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesCompleteRestoreFuture) Result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCompleteRestoreFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.CompleteRestoreResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.CompleteRestoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedDatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesCreateOrUpdateFuture) Result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return md, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + md, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + md, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedDatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesDeleteFuture) Result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedDatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesUpdateFuture) Result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return md, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + md, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", resp, "Failure sending request") + return + } + md, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", resp, "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 +} + +// 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 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = mi.Tags + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.ID != nil { + objectMap["id"] = mi.ID + } + if mi.Name != nil { + objectMap["name"] = mi.Name + } + if mi.Type != nil { + objectMap["type"] = mi.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + 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 - Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer() (*http.Request, error) { + if milr.NextLink == nil || len(to.String(milr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceListResultPage) Next() error { + next, err := page.fn(page.milr) + if err != nil { + return err + } + page.milr = next + return nil +} + +// 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 +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // FullyQualifiedDomainName - 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 - The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' and 'BasePrice'. + LicenseType *string `json:"licenseType,omitempty"` + // VCores - The number of VCores. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - The maximum storage size in GB. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesCreateOrUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesDeleteFuture) Result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "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 limits for a database. +type MaxSizeCapability struct { + // Limit - The maximum size of the database (see 'unit' for the units). + Limit *int64 `json:"limit,omitempty"` + // Unit - The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes' + Unit MaxSizeUnits `json:"unit,omitempty"` + // Status - The status of the maximum size capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` +} + +// Metric database metrics. +type Metric struct { + // StartTime - The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - The time step to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' + Unit UnitType `json:"unit,omitempty"` + // Name - The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MetricAvailability a metric availability value. +type MetricAvailability struct { + // Retention - The length of retention for the database metric. + Retention *string `json:"retention,omitempty"` + // TimeGrain - The granularity of the database metric. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MetricDefinition a database metric definition. +type MetricDefinition struct { + // Name - The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // PrimaryAggregationType - The primary aggregation type defining how metric values are displayed. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // ResourceURI - The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' + Unit UnitDefinitionType `json:"unit,omitempty"` + // MetricAvailabilities - The list of database metric availabities for the metric. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` +} + +// 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 - The name of the database metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - The friendly name of the database metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MetricValue represents database metrics. +type MetricValue struct { + // Count - The number of values for the metric. + Count *float64 `json:"count,omitempty"` + // Average - The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// Operation SQL REST API operation definition. +type Operation struct { + // Name - The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - The localized display information for this particular operation / action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The intended executor of the operation. Possible values include: 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - 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{}) + if o.Name != nil { + objectMap["name"] = o.Name + } + if o.Display != nil { + objectMap["display"] = o.Display + } + if o.Origin != "" { + objectMap["origin"] = o.Origin + } + if o.Properties != nil { + objectMap["properties"] = o.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - The localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - The localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` + // Operation - The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - The localized friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// OperationImpact the impact of an operation, both in absolute and relative terms. +type OperationImpact struct { + // Name - The name of the impact dimension. + Name *string `json:"name,omitempty"` + // Unit - The unit in which estimated impact to dimension is measured. + Unit *string `json:"unit,omitempty"` + // ChangeValueAbsolute - The absolute impact to dimension. + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - The relative impact to dimension (null if not applicable) + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// OperationListResult result of the request to list SQL operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]Operation `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// 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 +} + +// PartnerInfo partner server information for the failover group. +type PartnerInfo struct { + // ID - Resource identifier of the partner server. + ID *string `json:"id,omitempty"` + // Location - Geo location of the partner server. + Location *string `json:"location,omitempty"` + // ReplicationRole - Replication role of the partner server. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// PerformanceLevel a possible performance level of a service objective capability. +type PerformanceLevel struct { + // Unit - Unit type used to measure service objective performance level. Possible values include: 'DTU' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // Value - Performance level value. + Value *int32 `json:"value,omitempty"` +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// RecommendedIndex represents a database recommended index. +type RecommendedIndex struct { + // RecommendedIndexProperties - The properties representing the resource. + *RecommendedIndexProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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{}) + if ri.RecommendedIndexProperties != nil { + objectMap["properties"] = ri.RecommendedIndexProperties + } + if ri.ID != nil { + objectMap["id"] = ri.ID + } + if ri.Name != nil { + objectMap["name"] = ri.Name + } + if ri.Type != nil { + objectMap["type"] = ri.Type + } + 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 - The proposed index action. You can create a missing index, drop an unused index, or rebuild an existing index to improve its performance. Possible values include: 'Create', 'Drop', 'Rebuild' + Action RecommendedIndexAction `json:"action,omitempty"` + // State - The current recommendation state. Possible values include: 'RecommendedIndexStateActive', 'RecommendedIndexStatePending', 'RecommendedIndexStateExecuting', 'RecommendedIndexStateVerifying', 'RecommendedIndexStatePendingRevert', 'RecommendedIndexStateReverting', 'RecommendedIndexStateReverted', 'RecommendedIndexStateIgnored', 'RecommendedIndexStateExpired', 'RecommendedIndexStateBlocked', 'RecommendedIndexStateSuccess' + State RecommendedIndexState `json:"state,omitempty"` + // Created - The UTC datetime showing when this resource was created (ISO8601 format). + Created *date.Time `json:"created,omitempty"` + // LastModified - The UTC datetime of when was this resource last changed (ISO8601 format). + LastModified *date.Time `json:"lastModified,omitempty"` + // IndexType - The type of index (CLUSTERED, NONCLUSTERED, COLUMNSTORE, CLUSTERED COLUMNSTORE). Possible values include: 'CLUSTERED', 'NONCLUSTERED', 'COLUMNSTORE', 'CLUSTEREDCOLUMNSTORE' + IndexType RecommendedIndexType `json:"indexType,omitempty"` + // Schema - The schema where table to build index over resides + Schema *string `json:"schema,omitempty"` + // Table - The table on which to build index. + Table *string `json:"table,omitempty"` + // Columns - Columns over which to build index + Columns *[]string `json:"columns,omitempty"` + // IncludedColumns - The list of column names to be included in the index + IncludedColumns *[]string `json:"includedColumns,omitempty"` + // IndexScript - The full build index script + IndexScript *string `json:"indexScript,omitempty"` + // EstimatedImpact - The estimated impact of doing recommended index action. + EstimatedImpact *[]OperationImpact `json:"estimatedImpact,omitempty"` + // ReportedImpact - The values reported after index action is complete. + ReportedImpact *[]OperationImpact `json:"reportedImpact,omitempty"` +} + +// RecoverableDatabase a recoverable database +type RecoverableDatabase struct { + autorest.Response `json:"-"` + // RecoverableDatabaseProperties - The properties of a recoverable database + *RecoverableDatabaseProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if rd.ID != nil { + objectMap["id"] = rd.ID + } + if rd.Name != nil { + objectMap["name"] = rd.Name + } + if rd.Type != nil { + objectMap["type"] = rd.Type + } + 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 - The edition of the database + Edition *string `json:"edition,omitempty"` + // ServiceLevelObjective - The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // LastAvailableBackupDate - The last available backup date of the database (ISO8601 format) + LastAvailableBackupDate *date.Time `json:"lastAvailableBackupDate,omitempty"` +} + +// ReplicationLink represents a database replication link. +type ReplicationLink struct { + autorest.Response `json:"-"` + // Location - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = rl.Location + } + if rl.ReplicationLinkProperties != nil { + objectMap["properties"] = rl.ReplicationLinkProperties + } + if rl.ID != nil { + objectMap["id"] = rl.ID + } + if rl.Name != nil { + objectMap["name"] = rl.Name + } + if rl.Type != nil { + objectMap["type"] = rl.Type + } + 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 - Legacy value indicating whether termination is allowed. Currently always returns true. + IsTerminationAllowed *bool `json:"isTerminationAllowed,omitempty"` + // ReplicationMode - Replication mode of this replication link. + ReplicationMode *string `json:"replicationMode,omitempty"` + // PartnerServer - The name of the server hosting the partner database. + PartnerServer *string `json:"partnerServer,omitempty"` + // PartnerDatabase - The name of the partner database. + PartnerDatabase *string `json:"partnerDatabase,omitempty"` + // PartnerLocation - The Azure Region of the partner database. + PartnerLocation *string `json:"partnerLocation,omitempty"` + // Role - The role of the database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + Role ReplicationRole `json:"role,omitempty"` + // PartnerRole - The role of the partner database in the replication link. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + PartnerRole ReplicationRole `json:"partnerRole,omitempty"` + // StartTime - The start time for the replication link. + StartTime *date.Time `json:"startTime,omitempty"` + // PercentComplete - The percentage of seeding complete for the replication link. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ReplicationState - The replication state for the replication link. Possible values include: 'PENDING', 'SEEDING', 'CATCHUP', 'SUSPENDED' + ReplicationState ReplicationState `json:"replicationState,omitempty"` +} + +// ReplicationLinksFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ReplicationLinksFailoverAllowDataLossFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ReplicationLinksFailoverAllowDataLossFuture) Result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.FailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.FailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReplicationLinksFailoverFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ReplicationLinksFailoverFuture) Result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", resp, "Failure responding to request") + } + return +} + +// Resource ARM resource. +type Resource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// ResourceIdentity azure Active Directory identity configuration for a resource. +type ResourceIdentity struct { + // PrincipalID - 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 IdentityType `json:"type,omitempty"` + // TenantID - The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// 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 - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = rdd.Location + } + if rdd.RestorableDroppedDatabaseProperties != nil { + objectMap["properties"] = rdd.RestorableDroppedDatabaseProperties + } + if rdd.ID != nil { + objectMap["id"] = rdd.ID + } + if rdd.Name != nil { + objectMap["name"] = rdd.Name + } + if rdd.Type != nil { + objectMap["type"] = rdd.Type + } + 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 - The name of the database + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - The edition of the database + Edition *string `json:"edition,omitempty"` + // MaxSizeBytes - The max size in bytes of the database + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // ServiceLevelObjective - The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // CreationDate - The creation date of the database (ISO8601 format) + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - The deletion date of the database (ISO8601 format) + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - The earliest restore date of the database (ISO8601 format) + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// RestorePoint database restore points. +type RestorePoint struct { + autorest.Response `json:"-"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // RestorePointProperties - Resource properties. + *RestorePointProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = rp.Location + } + if rp.RestorePointProperties != nil { + objectMap["properties"] = rp.RestorePointProperties + } + if rp.ID != nil { + objectMap["id"] = rp.ID + } + if rp.Name != nil { + objectMap["name"] = rp.Name + } + if rp.Type != nil { + objectMap["type"] = rp.Type + } + 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 bacukps. +type RestorePointListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]RestorePoint `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RestorePointProperties properties of a database restore point +type RestorePointProperties struct { + // RestorePointType - The type of restore point. Possible values include: 'CONTINUOUS', 'DISCRETE' + RestorePointType RestorePointType `json:"restorePointType,omitempty"` + // EarliestRestoreDate - The earliest time to which this database can be restored + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // RestorePointCreationDate - The time the backup was taken + RestorePointCreationDate *date.Time `json:"restorePointCreationDate,omitempty"` + // RestorePointLabel - The label of restore point for backup request by user + RestorePointLabel *string `json:"restorePointLabel,omitempty"` +} + +// RestorePointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type RestorePointsCreateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future RestorePointsCreateFuture) Result(client RestorePointsClient) (rp RestorePoint, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return rp, azure.NewAsyncOpIncompleteError("sql.RestorePointsCreateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + rp, err = client.CreateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", resp, "Failure sending request") + return + } + rp, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - 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"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = s.Kind + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.ID != nil { + objectMap["id"] = s.ID + } + if s.Name != nil { + objectMap["name"] = s.Name + } + if s.Type != nil { + objectMap["type"] = s.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + 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"` +} + +// ServerAutomaticTuning server-level Automatic Tuning. +type ServerAutomaticTuning struct { + autorest.Response `json:"-"` + // AutomaticTuningServerProperties - Resource properties. + *AutomaticTuningServerProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sat.ID != nil { + objectMap["id"] = sat.ID + } + if sat.Name != nil { + objectMap["name"] = sat.Name + } + if sat.Type != nil { + objectMap["type"] = sat.Type + } + 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 an server Active Directory Administrator. +type ServerAzureADAdministrator struct { + autorest.Response `json:"-"` + // ServerAdministratorProperties - The properties of the resource. + *ServerAdministratorProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if saaa.ID != nil { + objectMap["id"] = saaa.ID + } + if saaa.Name != nil { + objectMap["name"] = saaa.Name + } + if saaa.Type != nil { + objectMap["type"] = saaa.Type + } + 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerAzureADAdministratorsCreateOrUpdateFuture) Result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + saaa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + saaa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerAzureADAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerAzureADAdministratorsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerAzureADAdministratorsDeleteFuture) Result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return saaa, azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + saaa, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure sending request") + return + } + saaa, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerCommunicationLink server communication link. +type ServerCommunicationLink struct { + autorest.Response `json:"-"` + // ServerCommunicationLinkProperties - The properties of resource. + *ServerCommunicationLinkProperties `json:"properties,omitempty"` + // Location - Communication link location. + Location *string `json:"location,omitempty"` + // Kind - Communication link kind. This property is used for Azure Portal metadata. + Kind *string `json:"kind,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if scl.Location != nil { + objectMap["location"] = scl.Location + } + if scl.Kind != nil { + objectMap["kind"] = scl.Kind + } + if scl.ID != nil { + objectMap["id"] = scl.ID + } + if scl.Name != nil { + objectMap["name"] = scl.Name + } + if scl.Type != nil { + objectMap["type"] = scl.Type + } + 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 - The state. + State *string `json:"state,omitempty"` + // PartnerServer - The name of the partner server. + PartnerServer *string `json:"partnerServer,omitempty"` +} + +// ServerCommunicationLinksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerCommunicationLinksCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerCommunicationLinksCreateOrUpdateFuture) Result(client ServerCommunicationLinksClient) (scl ServerCommunicationLink, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return scl, azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + scl, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + scl, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerConnectionPolicy a server secure connection policy. +type ServerConnectionPolicy struct { + autorest.Response `json:"-"` + // Kind - Metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ServerConnectionPolicyProperties - The properties of the server secure connection policy. + *ServerConnectionPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = scp.Kind + } + if scp.Location != nil { + objectMap["location"] = scp.Location + } + if scp.ServerConnectionPolicyProperties != nil { + objectMap["properties"] = scp.ServerConnectionPolicyProperties + } + if scp.ID != nil { + objectMap["id"] = scp.ID + } + if scp.Name != nil { + objectMap["name"] = scp.Name + } + if scp.Type != nil { + objectMap["type"] = scp.Type + } + 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sda.ID != nil { + objectMap["id"] = sda.ID + } + if sda.Name != nil { + objectMap["name"] = sda.Name + } + if sda.Type != nil { + objectMap["type"] = sda.Type + } + 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerDNSAliasesAcquireFuture) Result(client ServerDNSAliasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesAcquireFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.AcquireResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.AcquireResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerDNSAliasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerDNSAliasesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerDNSAliasesCreateOrUpdateFuture) Result(client ServerDNSAliasesClient) (sda ServerDNSAlias, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sda, azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sda, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sda, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerDNSAliasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerDNSAliasesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerDNSAliasesDeleteFuture) Result(client ServerDNSAliasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerDNSAliasListResult a list of server DNS aliases. +type ServerDNSAliasListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]ServerDNSAlias `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerDNSAliasListResultIterator provides access to a complete listing of ServerDNSAlias values. +type ServerDNSAliasListResultIterator struct { + i int + page ServerDNSAliasListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerDNSAliasListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdalr ServerDNSAliasListResult) IsEmpty() bool { + return sdalr.Value == nil || len(*sdalr.Value) == 0 +} + +// serverDNSAliasListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdalr ServerDNSAliasListResult) serverDNSAliasListResultPreparer() (*http.Request, error) { + if sdalr.NextLink == nil || len(to.String(sdalr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdalr.NextLink))) +} + +// ServerDNSAliasListResultPage contains a page of ServerDNSAlias values. +type ServerDNSAliasListResultPage struct { + fn func(ServerDNSAliasListResult) (ServerDNSAliasListResult, error) + sdalr ServerDNSAliasListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerDNSAliasListResultPage) Next() error { + next, err := page.fn(page.sdalr) + if err != nil { + return err + } + page.sdalr = next + return nil +} + +// 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 +} + +// ServerDNSAliasProperties properties of a server DNS alias. +type ServerDNSAliasProperties struct { + // AzureDNSRecord - The fully qualified DNS record for alias + AzureDNSRecord *string `json:"azureDnsRecord,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 - Resource location. + Location *string `json:"location,omitempty"` + // ServerKeyProperties - Resource properties. + *ServerKeyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = sk.Location + } + if sk.ServerKeyProperties != nil { + objectMap["properties"] = sk.ServerKeyProperties + } + if sk.ID != nil { + objectMap["id"] = sk.ID + } + if sk.Name != nil { + objectMap["name"] = sk.Name + } + if sk.Type != nil { + objectMap["type"] = sk.Type + } + 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 - Array of results. + Value *[]ServerKey `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerKeyListResultIterator provides access to a complete listing of ServerKey values. +type ServerKeyListResultIterator struct { + i int + page ServerKeyListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerKeyListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sklr ServerKeyListResult) IsEmpty() bool { + return sklr.Value == nil || len(*sklr.Value) == 0 +} + +// serverKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sklr ServerKeyListResult) serverKeyListResultPreparer() (*http.Request, error) { + if sklr.NextLink == nil || len(to.String(sklr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sklr.NextLink))) +} + +// ServerKeyListResultPage contains a page of ServerKey values. +type ServerKeyListResultPage struct { + fn func(ServerKeyListResult) (ServerKeyListResult, error) + sklr ServerKeyListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerKeyListResultPage) Next() error { + next, err := page.fn(page.sklr) + if err != nil { + return err + } + page.sklr = next + return nil +} + +// 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 +} + +// ServerKeyProperties properties for a server key execution. +type ServerKeyProperties struct { + // Subregion - 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"` +} + +// ServerKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerKeysCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerKeysCreateOrUpdateFuture) Result(client ServerKeysClient) (sk ServerKey, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sk, azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sk, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sk, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerKeysDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServerKeysDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServerKeysDeleteFuture) Result(client ServerKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]Server `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer() (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerListResultPage) Next() error { + next, err := page.fn(page.slr) + if err != nil { + return err + } + page.slr = next + return nil +} + +// 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 +} + +// 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 - The state of the server. + State *string `json:"state,omitempty"` + // FullyQualifiedDomainName - The fully qualified domain name of the server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` +} + +// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServersCreateOrUpdateFuture) Result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return s, azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + s, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + s, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServersDeleteFuture) Result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ServersUpdateFuture) Result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return s, azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + s, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure sending request") + return + } + s, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Name of the server usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - The metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - The current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - The current limit of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - The units of the metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - The next reset time for the metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// 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 capabilities. +type ServerVersionCapability struct { + // Name - The server version name. + Name *string `json:"name,omitempty"` + // Status - The status of the server version. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // SupportedEditions - The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if so.ID != nil { + objectMap["id"] = so.ID + } + if so.Name != nil { + objectMap["name"] = so.Name + } + if so.Type != nil { + objectMap["type"] = so.Type + } + 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 { + // Name - The service objective name. + Name *string `json:"name,omitempty"` + // Status - The status of the service objective. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // PerformanceLevel - The performance level of the service objective capability. + *PerformanceLevel `json:"performanceLevel,omitempty"` + // ID - The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // SupportedMaxSizes - The list of supported maximum database sizes for this service objective. + SupportedMaxSizes *[]MaxSizeCapability `json:"supportedMaxSizes,omitempty"` + // IncludedMaxSize - The included (free) max size for this service level objective. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveCapability. +func (soc ServiceObjectiveCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if soc.Name != nil { + objectMap["name"] = soc.Name + } + if soc.Status != "" { + objectMap["status"] = soc.Status + } + if soc.PerformanceLevel != nil { + objectMap["performanceLevel"] = soc.PerformanceLevel + } + if soc.ID != nil { + objectMap["id"] = soc.ID + } + if soc.SupportedMaxSizes != nil { + objectMap["supportedMaxSizes"] = soc.SupportedMaxSizes + } + if soc.IncludedMaxSize != nil { + objectMap["includedMaxSize"] = soc.IncludedMaxSize + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceObjectiveCapability struct. +func (soc *ServiceObjectiveCapability) 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 + } + soc.Name = &name + } + case "status": + if v != nil { + var status CapabilityStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + soc.Status = status + } + case "performanceLevel": + if v != nil { + var performanceLevel PerformanceLevel + err = json.Unmarshal(*v, &performanceLevel) + if err != nil { + return err + } + soc.PerformanceLevel = &performanceLevel + } + case "id": + if v != nil { + var ID uuid.UUID + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + soc.ID = &ID + } + case "supportedMaxSizes": + if v != nil { + var supportedMaxSizes []MaxSizeCapability + err = json.Unmarshal(*v, &supportedMaxSizes) + if err != nil { + return err + } + soc.SupportedMaxSizes = &supportedMaxSizes + } + case "includedMaxSize": + if v != nil { + var includedMaxSize MaxSizeCapability + err = json.Unmarshal(*v, &includedMaxSize) + if err != nil { + return err + } + soc.IncludedMaxSize = &includedMaxSize + } + } + } + + 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 - The name for the service objective. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // IsDefault - Gets whether the service level objective is the default service objective. + IsDefault *bool `json:"isDefault,omitempty"` + // IsSystem - Gets whether the service level objective is a system service objective. + IsSystem *bool `json:"isSystem,omitempty"` + // Description - The description for the service level objective. + Description *string `json:"description,omitempty"` + // Enabled - Gets whether the service level objective is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// ServiceTierAdvisor represents a Service Tier Advisor. +type ServiceTierAdvisor struct { + autorest.Response `json:"-"` + // ServiceTierAdvisorProperties - The properites representing the resource. + *ServiceTierAdvisorProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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{}) + if sta.ServiceTierAdvisorProperties != nil { + objectMap["properties"] = sta.ServiceTierAdvisorProperties + } + if sta.ID != nil { + objectMap["id"] = sta.ID + } + if sta.Name != nil { + objectMap["name"] = sta.Name + } + if sta.Type != nil { + objectMap["type"] = sta.Type + } + 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 - The observation period start (ISO8601 format). + ObservationPeriodStart *date.Time `json:"observationPeriodStart,omitempty"` + // ObservationPeriodEnd - The observation period start (ISO8601 format). + ObservationPeriodEnd *date.Time `json:"observationPeriodEnd,omitempty"` + // ActiveTimeRatio - The activeTimeRatio for service tier advisor. + ActiveTimeRatio *float64 `json:"activeTimeRatio,omitempty"` + // MinDtu - Gets or sets minDtu for service tier advisor. + MinDtu *float64 `json:"minDtu,omitempty"` + // AvgDtu - Gets or sets avgDtu for service tier advisor. + AvgDtu *float64 `json:"avgDtu,omitempty"` + // MaxDtu - Gets or sets maxDtu for service tier advisor. + MaxDtu *float64 `json:"maxDtu,omitempty"` + // MaxSizeInGB - Gets or sets maxSizeInGB for service tier advisor. + MaxSizeInGB *float64 `json:"maxSizeInGB,omitempty"` + // ServiceLevelObjectiveUsageMetrics - Gets or sets serviceLevelObjectiveUsageMetrics for the service tier advisor. + ServiceLevelObjectiveUsageMetrics *[]SloUsageMetric `json:"serviceLevelObjectiveUsageMetrics,omitempty"` + // CurrentServiceLevelObjective - Gets or sets currentServiceLevelObjective for service tier advisor. + CurrentServiceLevelObjective *string `json:"currentServiceLevelObjective,omitempty"` + // CurrentServiceLevelObjectiveID - Gets or sets currentServiceLevelObjectiveId for service tier advisor. + CurrentServiceLevelObjectiveID *uuid.UUID `json:"currentServiceLevelObjectiveId,omitempty"` + // UsageBasedRecommendationServiceLevelObjective - Gets or sets usageBasedRecommendationServiceLevelObjective for service tier advisor. + UsageBasedRecommendationServiceLevelObjective *string `json:"usageBasedRecommendationServiceLevelObjective,omitempty"` + // UsageBasedRecommendationServiceLevelObjectiveID - Gets or sets usageBasedRecommendationServiceLevelObjectiveId for service tier advisor. + UsageBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"usageBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjective - Gets or sets databaseSizeBasedRecommendationServiceLevelObjective for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjective *string `json:"databaseSizeBasedRecommendationServiceLevelObjective,omitempty"` + // DatabaseSizeBasedRecommendationServiceLevelObjectiveID - Gets or sets databaseSizeBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DatabaseSizeBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"databaseSizeBasedRecommendationServiceLevelObjectiveId,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjective - Gets or sets disasterPlanBasedRecommendationServiceLevelObjective for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjective *string `json:"disasterPlanBasedRecommendationServiceLevelObjective,omitempty"` + // DisasterPlanBasedRecommendationServiceLevelObjectiveID - Gets or sets disasterPlanBasedRecommendationServiceLevelObjectiveId for service tier advisor. + DisasterPlanBasedRecommendationServiceLevelObjectiveID *uuid.UUID `json:"disasterPlanBasedRecommendationServiceLevelObjectiveId,omitempty"` + // OverallRecommendationServiceLevelObjective - Gets or sets overallRecommendationServiceLevelObjective for service tier advisor. + OverallRecommendationServiceLevelObjective *string `json:"overallRecommendationServiceLevelObjective,omitempty"` + // OverallRecommendationServiceLevelObjectiveID - Gets or sets overallRecommendationServiceLevelObjectiveId for service tier advisor. + OverallRecommendationServiceLevelObjectiveID *uuid.UUID `json:"overallRecommendationServiceLevelObjectiveId,omitempty"` + // Confidence - Gets or sets confidence for service tier advisor. + Confidence *float64 `json:"confidence,omitempty"` +} + +// 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 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 - 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 - The serviceLevelObjectiveId for SLO usage metric. + ServiceLevelObjectiveID *uuid.UUID `json:"serviceLevelObjectiveId,omitempty"` + // InRangeTimeRatio - Gets or sets inRangeTimeRatio for SLO usage metric. + InRangeTimeRatio *float64 `json:"inRangeTimeRatio,omitempty"` +} + +// SubscriptionUsage usage Metric of a Subscription in a Location. +type SubscriptionUsage struct { + autorest.Response `json:"-"` + // SubscriptionUsageProperties - Resource properties. + *SubscriptionUsageProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if su.ID != nil { + objectMap["id"] = su.ID + } + if su.Name != nil { + objectMap["name"] = su.Name + } + if su.Type != nil { + objectMap["type"] = su.Type + } + 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 - Array of results. + Value *[]SubscriptionUsage `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SubscriptionUsageListResultIterator provides access to a complete listing of SubscriptionUsage values. +type SubscriptionUsageListResultIterator struct { + i int + page SubscriptionUsageListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SubscriptionUsageListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sulr SubscriptionUsageListResult) IsEmpty() bool { + return sulr.Value == nil || len(*sulr.Value) == 0 +} + +// subscriptionUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sulr SubscriptionUsageListResult) subscriptionUsageListResultPreparer() (*http.Request, error) { + if sulr.NextLink == nil || len(to.String(sulr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sulr.NextLink))) +} + +// SubscriptionUsageListResultPage contains a page of SubscriptionUsage values. +type SubscriptionUsageListResultPage struct { + fn func(SubscriptionUsageListResult) (SubscriptionUsageListResult, error) + sulr SubscriptionUsageListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SubscriptionUsageListResultPage) Next() error { + next, err := page.fn(page.sulr) + if err != nil { + return err + } + page.sulr = next + return nil +} + +// 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 +} + +// SubscriptionUsageProperties properties of a subscription usage. +type SubscriptionUsageProperties struct { + // DisplayName - User-readable name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - Current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - Boundary value of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - Unit of the metric. + Unit *string `json:"unit,omitempty"` +} + +// SyncAgent an Azure SQL Database sync agent. +type SyncAgent struct { + autorest.Response `json:"-"` + // SyncAgentProperties - Resource properties. + *SyncAgentProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sa.ID != nil { + objectMap["id"] = sa.ID + } + if sa.Name != nil { + objectMap["name"] = sa.Name + } + if sa.Type != nil { + objectMap["type"] = sa.Type + } + 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 - Key of sync agent. + SyncAgentKey *string `json:"syncAgentKey,omitempty"` +} + +// SyncAgentLinkedDatabase an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabase struct { + // SyncAgentLinkedDatabaseProperties - Resource properties. + *SyncAgentLinkedDatabaseProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sald.ID != nil { + objectMap["id"] = sald.ID + } + if sald.Name != nil { + objectMap["name"] = sald.Name + } + if sald.Type != nil { + objectMap["type"] = sald.Type + } + 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 - Array of results. + Value *[]SyncAgentLinkedDatabase `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncAgentLinkedDatabaseListResultIterator provides access to a complete listing of SyncAgentLinkedDatabase +// values. +type SyncAgentLinkedDatabaseListResultIterator struct { + i int + page SyncAgentLinkedDatabaseListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncAgentLinkedDatabaseListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (saldlr SyncAgentLinkedDatabaseListResult) IsEmpty() bool { + return saldlr.Value == nil || len(*saldlr.Value) == 0 +} + +// syncAgentLinkedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (saldlr SyncAgentLinkedDatabaseListResult) syncAgentLinkedDatabaseListResultPreparer() (*http.Request, error) { + if saldlr.NextLink == nil || len(to.String(saldlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(saldlr.NextLink))) +} + +// SyncAgentLinkedDatabaseListResultPage contains a page of SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultPage struct { + fn func(SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error) + saldlr SyncAgentLinkedDatabaseListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncAgentLinkedDatabaseListResultPage) Next() error { + next, err := page.fn(page.saldlr) + if err != nil { + return err + } + page.saldlr = next + return nil +} + +// 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 +} + +// SyncAgentLinkedDatabaseProperties properties of an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabaseProperties struct { + // DatabaseType - Type of the sync agent linked database. Possible values include: 'AzureSQLDatabase', 'SQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // DatabaseID - Id of the sync agent linked database. + DatabaseID *string `json:"databaseId,omitempty"` + // Description - Description of the sync agent linked database. + Description *string `json:"description,omitempty"` + // ServerName - Server name of the sync agent linked database. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - Database name of the sync agent linked database. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - User name of the sync agent linked database. + UserName *string `json:"userName,omitempty"` +} + +// SyncAgentListResult a list of sync agents. +type SyncAgentListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncAgent `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncAgentListResultIterator provides access to a complete listing of SyncAgent values. +type SyncAgentListResultIterator struct { + i int + page SyncAgentListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncAgentListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (salr SyncAgentListResult) IsEmpty() bool { + return salr.Value == nil || len(*salr.Value) == 0 +} + +// syncAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (salr SyncAgentListResult) syncAgentListResultPreparer() (*http.Request, error) { + if salr.NextLink == nil || len(to.String(salr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(salr.NextLink))) +} + +// SyncAgentListResultPage contains a page of SyncAgent values. +type SyncAgentListResultPage struct { + fn func(SyncAgentListResult) (SyncAgentListResult, error) + salr SyncAgentListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncAgentListResultPage) Next() error { + next, err := page.fn(page.salr) + if err != nil { + return err + } + page.salr = next + return nil +} + +// 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 +} + +// SyncAgentProperties properties of an Azure SQL Database sync agent. +type SyncAgentProperties struct { + // Name - 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 - Last alive time of the sync agent. + LastAliveTime *date.Time `json:"lastAliveTime,omitempty"` + // State - State of the sync agent. Possible values include: 'SyncAgentStateOnline', 'SyncAgentStateOffline', 'SyncAgentStateNeverConnected' + State SyncAgentState `json:"state,omitempty"` + // IsUpToDate - If the sync agent version is up to date. + IsUpToDate *bool `json:"isUpToDate,omitempty"` + // ExpiryTime - Expiration time of the sync agent version. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Version - Version of the sync agent. + Version *string `json:"version,omitempty"` +} + +// SyncAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncAgentsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncAgentsCreateOrUpdateFuture) Result(client SyncAgentsClient) (sa SyncAgent, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sa, azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sa, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sa, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncAgentsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncAgentsDeleteFuture) Result(client SyncAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncDatabaseIDListResult a list of sync database ID properties. +type SyncDatabaseIDListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncDatabaseIDProperties `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncDatabaseIDListResultIterator provides access to a complete listing of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultIterator struct { + i int + page SyncDatabaseIDListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncDatabaseIDListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdilr SyncDatabaseIDListResult) IsEmpty() bool { + return sdilr.Value == nil || len(*sdilr.Value) == 0 +} + +// syncDatabaseIDListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdilr SyncDatabaseIDListResult) syncDatabaseIDListResultPreparer() (*http.Request, error) { + if sdilr.NextLink == nil || len(to.String(sdilr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdilr.NextLink))) +} + +// SyncDatabaseIDListResultPage contains a page of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultPage struct { + fn func(SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error) + sdilr SyncDatabaseIDListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncDatabaseIDListResultPage) Next() error { + next, err := page.fn(page.sdilr) + if err != nil { + return err + } + page.sdilr = next + return nil +} + +// 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 +} + +// SyncDatabaseIDProperties properties of the sync database id. +type SyncDatabaseIDProperties struct { + // ID - ARM resource id of sync database. + ID *string `json:"id,omitempty"` +} + +// SyncFullSchemaProperties properties of the database full schema. +type SyncFullSchemaProperties struct { + // Tables - List of tables in the database full schema. + Tables *[]SyncFullSchemaTable `json:"tables,omitempty"` + // LastUpdateTime - Last update time of the database schema. + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// SyncFullSchemaPropertiesListResult a list of sync schema properties. +type SyncFullSchemaPropertiesListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncFullSchemaProperties `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncFullSchemaPropertiesListResultIterator provides access to a complete listing of SyncFullSchemaProperties +// values. +type SyncFullSchemaPropertiesListResultIterator struct { + i int + page SyncFullSchemaPropertiesListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncFullSchemaPropertiesListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sfsplr SyncFullSchemaPropertiesListResult) IsEmpty() bool { + return sfsplr.Value == nil || len(*sfsplr.Value) == 0 +} + +// syncFullSchemaPropertiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sfsplr SyncFullSchemaPropertiesListResult) syncFullSchemaPropertiesListResultPreparer() (*http.Request, error) { + if sfsplr.NextLink == nil || len(to.String(sfsplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sfsplr.NextLink))) +} + +// SyncFullSchemaPropertiesListResultPage contains a page of SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultPage struct { + fn func(SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error) + sfsplr SyncFullSchemaPropertiesListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncFullSchemaPropertiesListResultPage) Next() error { + next, err := page.fn(page.sfsplr) + if err != nil { + return err + } + page.sfsplr = next + return nil +} + +// 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 +} + +// SyncFullSchemaTable properties of the table in the database full schema. +type SyncFullSchemaTable struct { + // Columns - List of columns in the table of database full schema. + Columns *[]SyncFullSchemaTableColumn `json:"columns,omitempty"` + // ErrorID - Error id of the table. + ErrorID *string `json:"errorId,omitempty"` + // HasError - If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // Name - Name of the table. + Name *string `json:"name,omitempty"` + // QuotedName - Quoted name of the table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncFullSchemaTableColumn properties of the column in the table of database full schema. +type SyncFullSchemaTableColumn struct { + // DataSize - Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - Data type of the column. + DataType *string `json:"dataType,omitempty"` + // ErrorID - Error id of the column. + ErrorID *string `json:"errorId,omitempty"` + // HasError - If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // IsPrimaryKey - If it is the primary key of the table. + IsPrimaryKey *bool `json:"isPrimaryKey,omitempty"` + // Name - Name of the column. + Name *string `json:"name,omitempty"` + // QuotedName - Quoted name of the column. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncGroup an Azure SQL Database sync group. +type SyncGroup struct { + autorest.Response `json:"-"` + // SyncGroupProperties - Resource properties. + *SyncGroupProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sg.ID != nil { + objectMap["id"] = sg.ID + } + if sg.Name != nil { + objectMap["name"] = sg.Name + } + if sg.Type != nil { + objectMap["type"] = sg.Type + } + 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 - Array of results. + Value *[]SyncGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncGroupListResultIterator provides access to a complete listing of SyncGroup values. +type SyncGroupListResultIterator struct { + i int + page SyncGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sglr SyncGroupListResult) IsEmpty() bool { + return sglr.Value == nil || len(*sglr.Value) == 0 +} + +// syncGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sglr SyncGroupListResult) syncGroupListResultPreparer() (*http.Request, error) { + if sglr.NextLink == nil || len(to.String(sglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sglr.NextLink))) +} + +// SyncGroupListResultPage contains a page of SyncGroup values. +type SyncGroupListResultPage struct { + fn func(SyncGroupListResult) (SyncGroupListResult, error) + sglr SyncGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncGroupListResultPage) Next() error { + next, err := page.fn(page.sglr) + if err != nil { + return err + } + page.sglr = next + return nil +} + +// 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 +} + +// SyncGroupLogListResult a list of sync group log properties. +type SyncGroupLogListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]SyncGroupLogProperties `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncGroupLogListResultIterator provides access to a complete listing of SyncGroupLogProperties values. +type SyncGroupLogListResultIterator struct { + i int + page SyncGroupLogListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncGroupLogListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (sgllr SyncGroupLogListResult) IsEmpty() bool { + return sgllr.Value == nil || len(*sgllr.Value) == 0 +} + +// syncGroupLogListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sgllr SyncGroupLogListResult) syncGroupLogListResultPreparer() (*http.Request, error) { + if sgllr.NextLink == nil || len(to.String(sgllr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sgllr.NextLink))) +} + +// SyncGroupLogListResultPage contains a page of SyncGroupLogProperties values. +type SyncGroupLogListResultPage struct { + fn func(SyncGroupLogListResult) (SyncGroupLogListResult, error) + sgllr SyncGroupLogListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncGroupLogListResultPage) Next() error { + next, err := page.fn(page.sgllr) + if err != nil { + return err + } + page.sgllr = next + return nil +} + +// 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 +} + +// SyncGroupLogProperties properties of an Azure SQL Database sync group log. +type SyncGroupLogProperties struct { + // Timestamp - Timestamp of the sync group log. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Type - Type of the sync group log. Possible values include: 'All', 'Error', 'Warning', 'Success' + Type SyncGroupLogType `json:"type,omitempty"` + // Source - Source of the sync group log. + Source *string `json:"source,omitempty"` + // Details - Details of the sync group log. + Details *string `json:"details,omitempty"` + // TracingID - TracingId of the sync group log. + TracingID *uuid.UUID `json:"tracingId,omitempty"` + // OperationStatus - OperationStatus of the sync group log. + OperationStatus *string `json:"operationStatus,omitempty"` +} + +// SyncGroupProperties properties of a sync group. +type SyncGroupProperties struct { + // Interval - Sync interval of the sync group. + Interval *int32 `json:"interval,omitempty"` + // LastSyncTime - 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 - Sync state of the sync group. Possible values include: 'SyncGroupStateNotReady', 'SyncGroupStateError', 'SyncGroupStateWarning', 'SyncGroupStateProgressing', 'SyncGroupStateGood' + SyncState SyncGroupState `json:"syncState,omitempty"` + // Schema - Sync schema of the sync group. + Schema *SyncGroupSchema `json:"schema,omitempty"` +} + +// 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsCreateOrUpdateFuture) Result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncGroupsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsDeleteFuture) Result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncGroupsRefreshHubSchemaFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsRefreshHubSchemaFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsRefreshHubSchemaFuture) Result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.RefreshHubSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.RefreshHubSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncGroupsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncGroupsUpdateFuture) Result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sg, azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sg, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure sending request") + return + } + sg, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMember an Azure SQL Database sync member. +type SyncMember struct { + autorest.Response `json:"-"` + // SyncMemberProperties - Resource properties. + *SyncMemberProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if sm.ID != nil { + objectMap["id"] = sm.ID + } + if sm.Name != nil { + objectMap["name"] = sm.Name + } + if sm.Type != nil { + objectMap["type"] = sm.Type + } + 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 - Array of results. + Value *[]SyncMember `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SyncMemberListResultIterator provides access to a complete listing of SyncMember values. +type SyncMemberListResultIterator struct { + i int + page SyncMemberListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncMemberListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (smlr SyncMemberListResult) IsEmpty() bool { + return smlr.Value == nil || len(*smlr.Value) == 0 +} + +// syncMemberListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smlr SyncMemberListResult) syncMemberListResultPreparer() (*http.Request, error) { + if smlr.NextLink == nil || len(to.String(smlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smlr.NextLink))) +} + +// SyncMemberListResultPage contains a page of SyncMember values. +type SyncMemberListResultPage struct { + fn func(SyncMemberListResult) (SyncMemberListResult, error) + smlr SyncMemberListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncMemberListResultPage) Next() error { + next, err := page.fn(page.smlr) + if err != nil { + return err + } + page.smlr = next + return nil +} + +// 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 +} + +// 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 - 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"` +} + +// SyncMembersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersCreateOrUpdateFuture) Result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sm, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + sm, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMembersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncMembersDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersDeleteFuture) Result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMembersRefreshMemberSchemaFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersRefreshMemberSchemaFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersRefreshMemberSchemaFuture) Result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.RefreshMemberSchemaResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.RefreshMemberSchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", resp, "Failure responding to request") + } + return +} + +// SyncMembersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type SyncMembersUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future SyncMembersUpdateFuture) Result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return sm, azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + sm, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure sending request") + return + } + sm, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// TrackedResource ARM tracked top level resource. +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} + +// TransparentDataEncryption represents a database transparent data encryption configuration. +type TransparentDataEncryption struct { + autorest.Response `json:"-"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionProperties - Represents the properties of the resource. + *TransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = tde.Location + } + if tde.TransparentDataEncryptionProperties != nil { + objectMap["properties"] = tde.TransparentDataEncryptionProperties + } + if tde.ID != nil { + objectMap["id"] = tde.ID + } + if tde.Name != nil { + objectMap["name"] = tde.Name + } + if tde.Type != nil { + objectMap["type"] = tde.Type + } + 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 - Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionActivityProperties - Represents the properties of the resource. + *TransparentDataEncryptionActivityProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Location != nil { + objectMap["location"] = tdea.Location + } + if tdea.TransparentDataEncryptionActivityProperties != nil { + objectMap["properties"] = tdea.TransparentDataEncryptionActivityProperties + } + if tdea.ID != nil { + objectMap["id"] = tdea.ID + } + if tdea.Name != nil { + objectMap["name"] = tdea.Name + } + if tdea.Type != nil { + objectMap["type"] = tdea.Type + } + 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 - The status of the database. Possible values include: 'Encrypting', 'Decrypting' + Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` + // PercentComplete - The percent complete of the transparent data encryption scan for a database. + PercentComplete *float64 `json:"percentComplete,omitempty"` +} + +// 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"` +} + +// VirtualNetworkRule a virtual network rule. +type VirtualNetworkRule struct { + autorest.Response `json:"-"` + // VirtualNetworkRuleProperties - Resource properties. + *VirtualNetworkRuleProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if vnr.ID != nil { + objectMap["id"] = vnr.ID + } + if vnr.Name != nil { + objectMap["name"] = vnr.Name + } + if vnr.Type != nil { + objectMap["type"] = vnr.Type + } + 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 - Array of results. + Value *[]VirtualNetworkRule `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// VirtualNetworkRuleListResultIterator provides access to a complete listing of VirtualNetworkRule values. +type VirtualNetworkRuleListResultIterator struct { + i int + page VirtualNetworkRuleListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VirtualNetworkRuleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (vnrlr VirtualNetworkRuleListResult) IsEmpty() bool { + return vnrlr.Value == nil || len(*vnrlr.Value) == 0 +} + +// virtualNetworkRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vnrlr VirtualNetworkRuleListResult) virtualNetworkRuleListResultPreparer() (*http.Request, error) { + if vnrlr.NextLink == nil || len(to.String(vnrlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vnrlr.NextLink))) +} + +// VirtualNetworkRuleListResultPage contains a page of VirtualNetworkRule values. +type VirtualNetworkRuleListResultPage struct { + fn func(VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error) + vnrlr VirtualNetworkRuleListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VirtualNetworkRuleListResultPage) Next() error { + next, err := page.fn(page.vnrlr) + if err != nil { + return err + } + page.vnrlr = next + return nil +} + +// 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 +} + +// 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 - Virtual Network Rule State. Possible values include: 'VirtualNetworkRuleStateInitializing', 'VirtualNetworkRuleStateInProgress', 'VirtualNetworkRuleStateReady', 'VirtualNetworkRuleStateDeleting', 'VirtualNetworkRuleStateUnknown' + State VirtualNetworkRuleState `json:"state,omitempty"` +} + +// VirtualNetworkRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future VirtualNetworkRulesCreateOrUpdateFuture) Result(client VirtualNetworkRulesClient) (vnr VirtualNetworkRule, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return vnr, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + vnr, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + vnr, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// VirtualNetworkRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualNetworkRulesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future VirtualNetworkRulesDeleteFuture) Result(client VirtualNetworkRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/operations.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/operations.go new file mode 100644 index 000000000000..d5c11bcff4cd --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/operations.go @@ -0,0 +1,128 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/recoverabledatabases.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/recoverabledatabases.go new file mode 100644 index 000000000000..54ac2e72645f --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/recoverabledatabases.go @@ -0,0 +1,178 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +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 +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database +func (client RecoverableDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RecoverableDatabase, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) GetResponder(resp *http.Response) (result RecoverableDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of recoverable databases +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client RecoverableDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableDatabaseListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) ListByServerResponder(resp *http.Response) (result RecoverableDatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/replicationlinks.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/replicationlinks.go new file mode 100644 index 000000000000..ad939db52788 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/replicationlinks.go @@ -0,0 +1,396 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewReplicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ReplicationLinksClient { + return ReplicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a database replication link. Cannot be done during failover. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database that has the replication link to be dropped. linkID is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover sets which replica database is primary by failing over from the current primary replica database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database that has the replication link to be failed over. linkID is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database that has the replication link to be failed over. linkID is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database replication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to get the link for. linkID is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) GetResponder(resp *http.Response) (result ReplicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists a database's replication links. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to retrieve links for. +func (client ReplicationLinksClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/restorabledroppeddatabases.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/restorabledroppeddatabases.go new file mode 100644 index 000000000000..f8813b6301f5 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/restorabledroppeddatabases.go @@ -0,0 +1,179 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewRestorableDroppedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedDatabasesClient { + return RestorableDroppedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a deleted database that can be restored +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +// restorableDroppededDatabaseID is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of deleted databases that can be restored +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client RestorableDroppedDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RestorableDroppedDatabaseListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) ListByServerResponder(resp *http.Response) (result RestorableDroppedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/restorepoints.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/restorepoints.go new file mode 100644 index 000000000000..979de007a06f --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/restorepoints.go @@ -0,0 +1,330 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewRestorePointsClientWithBaseURI(baseURI string, subscriptionID string) RestorePointsClient { + return RestorePointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a restore point for a data warehouse. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a restore point. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. restorePointName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a restore point. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. restorePointName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) GetResponder(resp *http.Response) (result RestorePoint, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database restore points. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client RestorePointsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RestorePointListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go new file mode 100644 index 000000000000..e71c53dbec2b --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverautomatictuning.go @@ -0,0 +1,179 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServerAutomaticTuningClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ServerAutomaticTuningClient struct { + BaseClient +} + +// NewServerAutomaticTuningClient creates an instance of the ServerAutomaticTuningClient client. +func NewServerAutomaticTuningClient(subscriptionID string) ServerAutomaticTuningClient { + return NewServerAutomaticTuningClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAutomaticTuningClientWithBaseURI creates an instance of the ServerAutomaticTuningClient client. +func NewServerAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) ServerAutomaticTuningClient { + return ServerAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieves server automatic tuning options. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAutomaticTuning, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAutomaticTuningClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAutomaticTuningClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAutomaticTuningClient) GetResponder(resp *http.Response) (result ServerAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning options on server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// automatic tuning resource state. +func (client ServerAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (result ServerAutomaticTuning, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServerAutomaticTuningClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServerAutomaticTuningClient) UpdateResponder(resp *http.Response) (result ServerAutomaticTuning, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serverazureadadministrators.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverazureadadministrators.go new file mode 100644 index 000000000000..ebdf54805877 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverazureadadministrators.go @@ -0,0 +1,333 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. properties is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory Administrator. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAzureADAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministratorsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) DeleteResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAzureADAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministrator, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) GetResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns a list of server Administrators. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerAzureADAdministratorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerAdministratorListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) ListByServerResponder(resp *http.Response) (result ServerAdministratorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/servercommunicationlinks.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/servercommunicationlinks.go new file mode 100644 index 000000000000..cb2a1fdd2420 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/servercommunicationlinks.go @@ -0,0 +1,328 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewServerCommunicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServerCommunicationLinksClient { + return ServerCommunicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a server communication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. communicationLinkName is the +// name of the server communication link. parameters is 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 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) CreateOrUpdateResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server communication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. communicationLinkName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a server communication link. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. communicationLinkName is the +// name of the server communication link. +func (client ServerCommunicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result ServerCommunicationLink, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) GetResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server communication links. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerCommunicationLinksClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerCommunicationLinkListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) ListByServerResponder(resp *http.Response) (result ServerCommunicationLinkListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serverconnectionpolicies.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverconnectionpolicies.go new file mode 100644 index 000000000000..1c02e43b9664 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverconnectionpolicies.go @@ -0,0 +1,181 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerConnectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerConnectionPoliciesClient { + return ServerConnectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's connection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the 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) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the server's secure connection policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerConnectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicy, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) GetResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serverdnsaliases.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverdnsaliases.go new file mode 100644 index 000000000000..1ab3795e1138 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverdnsaliases.go @@ -0,0 +1,420 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerDNSAliasesClientWithBaseURI(baseURI string, subscriptionID string) ServerDNSAliasesClient { + return ServerDNSAliasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Acquire acquires server DNS alias from another server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server that the alias is pointing +// to. DNSAliasName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates a server dns alias. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server that the alias is pointing +// to. DNSAliasName is the name of the server DNS alias. +func (client ServerDNSAliasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAliasesCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server DNS alias with the given name. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server that the alias is pointing +// to. DNSAliasName is the name of the server DNS alias. +func (client ServerDNSAliasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAliasesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server DNS alias. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server that the alias is pointing +// to. DNSAliasName is the name of the server DNS alias. +func (client ServerDNSAliasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAlias, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) GetResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server DNS aliases for a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server that the alias is pointing +// to. +func (client ServerDNSAliasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerDNSAliasListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) ListByServerResponder(resp *http.Response) (result ServerDNSAliasListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerDNSAliasesClient) listByServerNextResults(lastResults ServerDNSAliasListResult) (result ServerDNSAliasListResult, err error) { + req, err := lastResults.serverDNSAliasListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serverkeys.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverkeys.go new file mode 100644 index 000000000000..1808980a453e --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverkeys.go @@ -0,0 +1,353 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerKeysClientWithBaseURI(baseURI string, subscriptionID string) ServerKeysClient { + return ServerKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server key. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. keyName is 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 is 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) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server key with the given name. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. keyName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server key. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. keyName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) GetResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server keys. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerKeysClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) ListByServerResponder(resp *http.Response) (result ServerKeyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerKeysClient) listByServerNextResults(lastResults ServerKeyListResult) (result ServerKeyListResult, err error) { + req, err := lastResults.serverKeyListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/servers.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/servers.go new file mode 100644 index 000000000000..9fe738737cea --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/servers.go @@ -0,0 +1,579 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +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 is the parameters to request for name availability. +func (client ServersClient) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequest) (result CheckNameAvailabilityResponse, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// server resource state. +func (client ServersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateOrUpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of servers in a resource groups. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer() + 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) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. parameters is the requested +// server resource state. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (result ServersUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serverusages.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverusages.go new file mode 100644 index 000000000000..327be0cd0973 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serverusages.go @@ -0,0 +1,109 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServerUsagesClientWithBaseURI(baseURI string, subscriptionID string) ServerUsagesClient { + return ServerUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer returns server usages. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServerUsagesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerUsageListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerUsagesClient) ListByServerResponder(resp *http.Response) (result ServerUsageListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/serviceobjectives.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/serviceobjectives.go new file mode 100644 index 000000000000..4dd06885c982 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/serviceobjectives.go @@ -0,0 +1,178 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServiceObjectivesClientWithBaseURI(baseURI string, subscriptionID string) ServiceObjectivesClient { + return ServiceObjectivesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database service objective. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. serviceObjectiveName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) GetResponder(resp *http.Response) (result ServiceObjective, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns database service objectives. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ServiceObjectivesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServiceObjectiveListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) ListByServerResponder(resp *http.Response) (result ServiceObjectiveListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/servicetieradvisors.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/servicetieradvisors.go new file mode 100644 index 000000000000..581028cdec75 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/servicetieradvisors.go @@ -0,0 +1,181 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewServiceTierAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) ServiceTierAdvisorsClient { + return ServiceTierAdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a service tier advisor. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// database. serviceTierAdvisorName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceTierAdvisorsClient) GetResponder(resp *http.Response) (result ServiceTierAdvisor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns service tier advisors for specified database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// database. +func (client ServiceTierAdvisorsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ServiceTierAdvisorListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/subscriptionusages.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/subscriptionusages.go new file mode 100644 index 000000000000..6c014306f539 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/subscriptionusages.go @@ -0,0 +1,202 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSubscriptionUsagesClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionUsagesClient { + return SubscriptionUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a subscription usage metric. +// +// locationName is the name of the region where the resource is located. usageName is name of usage metric to +// return. +func (client SubscriptionUsagesClient) Get(ctx context.Context, locationName string, usageName string) (result SubscriptionUsage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) GetResponder(resp *http.Response) (result SubscriptionUsage, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// locationName is the name of the region where the resource is located. +func (client SubscriptionUsagesClient) ListByLocation(ctx context.Context, locationName string) (result SubscriptionUsageListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SubscriptionUsageListResult) (result SubscriptionUsageListResult, err error) { + req, err := lastResults.subscriptionUsageListResultPreparer() + 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) { + result.page, err = client.ListByLocation(ctx, locationName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/syncagents.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/syncagents.go new file mode 100644 index 000000000000..97ebdca602ea --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/syncagents.go @@ -0,0 +1,516 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSyncAgentsClientWithBaseURI(baseURI string, subscriptionID string) SyncAgentsClient { + return SyncAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateKey generates a sync agent key. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentKeyProperties, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgent, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GetResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists sync agents in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. +func (client SyncAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListByServerResponder(resp *http.Response) (result SyncAgentListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client SyncAgentsClient) listByServerNextResults(lastResults SyncAgentListResult) (result SyncAgentListResult, err error) { + req, err := lastResults.syncAgentListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// ListLinkedDatabases lists databases linked to a sync agent. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server on which the sync agent is +// hosted. syncAgentName is the name of the sync agent. +func (client SyncAgentsClient) ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncAgentLinkedDatabaseListResult) (result SyncAgentLinkedDatabaseListResult, err error) { + req, err := lastResults.syncAgentLinkedDatabaseListResultPreparer() + 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) { + result.page, err = client.ListLinkedDatabases(ctx, resourceGroupName, serverName, syncAgentName) + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/syncgroups.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/syncgroups.go new file mode 100644 index 000000000000..b08ba72a70d1 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/syncgroups.go @@ -0,0 +1,936 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient { + return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CancelSync cancels a sync group synchronization. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) GetResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists sync groups under a hub database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. +func (client SyncGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncGroupListResult) (result SyncGroupListResult, err error) { + req, err := lastResults.syncGroupListResultPreparer() + 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) { + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// ListHubSchemas gets a collection of hub database schemas. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer() + 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) { + result.page, err = client.ListHubSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListLogs gets a collection of sync group logs. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group. startTime is get +// logs generated after this time. endTime is get logs generated before this time. typeParameter is the types of +// logs to retrieve. continuationToken is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncGroupLogListResult) (result SyncGroupLogListResult, err error) { + req, err := lastResults.syncGroupLogListResultPreparer() + 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) { + result.page, err = client.ListLogs(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + return +} + +// ListSyncDatabaseIds gets a collection of sync database ids. +// +// locationName is the name of the region where the resource is located. +func (client SyncGroupsClient) ListSyncDatabaseIds(ctx context.Context, locationName string) (result SyncDatabaseIDListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncDatabaseIDListResult) (result SyncDatabaseIDListResult, err error) { + req, err := lastResults.syncDatabaseIDListResultPreparer() + 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) { + result.page, err = client.ListSyncDatabaseIds(ctx, locationName) + return +} + +// RefreshHubSchema refreshes a hub database schema. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// TriggerSync triggers a sync group synchronization. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates a sync group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) UpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/syncmembers.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/syncmembers.go new file mode 100644 index 000000000000..57554de42517 --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/syncmembers.go @@ -0,0 +1,612 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewSyncMembersClientWithBaseURI(baseURI string, subscriptionID string) SyncMembersClient { + return SyncMembersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is the name of the sync member. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) CreateOrUpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) GetResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncMemberListResult) (result SyncMemberListResult, err error) { + req, err := lastResults.syncMemberListResultPreparer() + 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) { + result.page, err = client.ListBySyncGroup(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListMemberSchemas gets a sync member database schema. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer() + 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) { + result.page, err = client.ListMemberSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + return +} + +// RefreshMemberSchema refreshes a sync member database schema. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing sync member. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database on which the sync group is hosted. syncGroupName is the name of the sync group on which the sync +// member is hosted. syncMemberName is the name of the sync member. parameters is 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) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) UpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/transparentdataencryptionactivities.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/transparentdataencryptionactivities.go new file mode 100644 index 000000000000..818a30dddf7c --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/transparentdataencryptionactivities.go @@ -0,0 +1,114 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewTransparentDataEncryptionActivitiesClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionActivitiesClient { + return TransparentDataEncryptionActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByConfiguration returns a database's transparent data encryption operation result. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionActivitiesClient) ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/transparentdataencryptions.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/transparentdataencryptions.go new file mode 100644 index 000000000000..87c20526f6ad --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/transparentdataencryptions.go @@ -0,0 +1,185 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewTransparentDataEncryptionsClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionsClient { + return TransparentDataEncryptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's transparent data encryption configuration. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which setting the transparent data encryption applies. parameters is 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) { + 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 +} + +// 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, + } + + 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's transparent data encryption configuration. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/2017-03-01-preview/sql/version.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/version.go new file mode 100644 index 000000000000..4e1611821a6f --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/version.go @@ -0,0 +1,30 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " sql/2017-03-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/2017-03-01-preview/sql/virtualnetworkrules.go b/services/preview/sql/mgmt/2017-03-01-preview/sql/virtualnetworkrules.go new file mode 100644 index 000000000000..336c296db9ff --- /dev/null +++ b/services/preview/sql/mgmt/2017-03-01-preview/sql/virtualnetworkrules.go @@ -0,0 +1,357 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewVirtualNetworkRulesClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkRulesClient { + return VirtualNetworkRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing virtual network rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. virtualNetworkRuleName is +// the name of the virtual network rule. parameters is 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 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the virtual network rule with the given name. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. virtualNetworkRuleName is +// the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRulesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual network rule. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. virtualNetworkRuleName is +// the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRule, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) GetResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of virtual network rules in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) ListByServerResponder(resp *http.Response) (result VirtualNetworkRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client VirtualNetworkRulesClient) listByServerNextResults(lastResults VirtualNetworkRuleListResult) (result VirtualNetworkRuleListResult, err error) { + req, err := lastResults.virtualNetworkRuleListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + 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..491d8eccde18 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/capabilities.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// 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. +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the subscription capabilities available for the specified location. +// +// locationName is the location name whose capabilities are retrieved. include is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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..e912a0c72d6b --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/client.go @@ -0,0 +1,52 @@ +// 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 and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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. +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..b241d9dad048 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/databaseoperations.go @@ -0,0 +1,209 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/satori/go.uuid" + "net/http" +) + +// 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. +func NewDatabaseOperationsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseOperationsClient { + return DatabaseOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. operationID is the operation identifier. +func (client DatabaseOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase gets a list of operations performed on the database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabaseOperationsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults DatabaseOperationListResult) (result DatabaseOperationListResult, err error) { + req, err := lastResults.databaseOperationListResultPreparer() + 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) { + 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..adeb7c5cf9d7 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/databases.go @@ -0,0 +1,819 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new database or updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the requested database resource state. +func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client DatabasesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer() + 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) { + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} + +// ListByServer gets a list of databases. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByServerNextResults(lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Pause pauses a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be paused. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Rename renames a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to rename. parameters is 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 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be resumed. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the requested database resource state. +func (client DatabasesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (result DatabasesUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeDataWarehouse upgrades a data warehouse. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database to be upgraded. +func (client DatabasesClient) UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesUpgradeDataWarehouseFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + 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..0ea385757754 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpooloperations.go @@ -0,0 +1,208 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/satori/go.uuid" + "net/http" +) + +// 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. +func NewElasticPoolOperationsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolOperationsClient { + return ElasticPoolOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. operationID is the operation +// identifier. +func (client ElasticPoolOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByElasticPool gets a list of operations performed on the elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. +func (client ElasticPoolOperationsClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ElasticPoolOperationListResult) (result ElasticPoolOperationListResult, err error) { + req, err := lastResults.elasticPoolOperationListResultPreparer() + 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) { + 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..31a8655c9fcd --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/elasticpools.go @@ -0,0 +1,434 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. parameters is the elastic pool parameters. +func (client ElasticPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (result ElasticPoolsCreateOrUpdateFuture, err error) { + 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, + } + + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client ElasticPoolsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. +func (client ElasticPoolsClient) Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPool, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all elastic pools in a server. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. skip is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ElasticPoolsClient) listByServerNextResults(lastResults ElasticPoolListResult) (result ElasticPoolListResult, err error) { + req, err := lastResults.elasticPoolListResultPreparer() + 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) { + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName, skip) + return +} + +// Update updates an elastic pool. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. elasticPoolName is the name +// of the elastic pool. parameters is the elastic pool update parameters. +func (client ElasticPoolsClient) Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (result ElasticPoolsUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..e82ba319e2fc --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go @@ -0,0 +1,504 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return InstanceFailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. parameters is the failover group parameters. +func (client InstanceFailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (result InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary managed instance to this managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsFailoverFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroup, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) GetResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists the failover groups in a location. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults InstanceFailoverGroupListResult) (result InstanceFailoverGroupListResult, err error) { + req, err := lastResults.instanceFailoverGroupListResultPreparer() + 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) { + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + 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..5079f31b7b53 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/models.go @@ -0,0 +1,2880 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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/satori/go.uuid" + "net/http" +) + +// 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 ( + // AutoClosed ... + AutoClosed DatabaseStatus = "AutoClosed" + // Copying ... + Copying DatabaseStatus = "Copying" + // Creating ... + Creating DatabaseStatus = "Creating" + // EmergencyMode ... + EmergencyMode DatabaseStatus = "EmergencyMode" + // Inaccessible ... + Inaccessible DatabaseStatus = "Inaccessible" + // Offline ... + Offline DatabaseStatus = "Offline" + // OfflineSecondary ... + OfflineSecondary DatabaseStatus = "OfflineSecondary" + // Online ... + Online DatabaseStatus = "Online" + // Paused ... + Paused DatabaseStatus = "Paused" + // Pausing ... + Pausing DatabaseStatus = "Pausing" + // Recovering ... + Recovering DatabaseStatus = "Recovering" + // RecoveryPending ... + RecoveryPending DatabaseStatus = "RecoveryPending" + // Restoring ... + Restoring DatabaseStatus = "Restoring" + // Resuming ... + Resuming DatabaseStatus = "Resuming" + // Scaling ... + Scaling DatabaseStatus = "Scaling" + // Shutdown ... + Shutdown DatabaseStatus = "Shutdown" + // Standby ... + Standby DatabaseStatus = "Standby" + // Suspect ... + Suspect DatabaseStatus = "Suspect" +) + +// PossibleDatabaseStatusValues returns an array of possible values for the DatabaseStatus const type. +func PossibleDatabaseStatusValues() []DatabaseStatus { + return []DatabaseStatus{AutoClosed, Copying, Creating, EmergencyMode, Inaccessible, Offline, OfflineSecondary, Online, Paused, Pausing, Recovering, RecoveryPending, Restoring, Resuming, Scaling, Shutdown, Standby, Suspect} +} + +// 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} +} + +// Database a database resource. +type Database struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // Kind - Kind of database. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedBy - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = d.Kind + } + if d.ManagedBy != nil { + objectMap["managedBy"] = d.ManagedBy + } + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Type != nil { + objectMap["type"] = d.Type + } + 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 - Array of results. + Value *[]Database `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer() (*http.Request, error) { + if dlr.NextLink == nil || len(to.String(dlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseListResultPage) Next() error { + next, err := page.fn(page.dlr) + if err != nil { + return err + } + page.dlr = next + return nil +} + +// 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 +} + +// DatabaseOperation a database operation. +type DatabaseOperation struct { + // DatabaseOperationProperties - Resource properties. + *DatabaseOperationProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if do.ID != nil { + objectMap["id"] = do.ID + } + if do.Name != nil { + objectMap["name"] = do.Name + } + if do.Type != nil { + objectMap["type"] = do.Type + } + 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 - Array of results. + Value *[]DatabaseOperation `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DatabaseOperationListResultIterator provides access to a complete listing of DatabaseOperation values. +type DatabaseOperationListResultIterator struct { + i int + page DatabaseOperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseOperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (dolr DatabaseOperationListResult) IsEmpty() bool { + return dolr.Value == nil || len(*dolr.Value) == 0 +} + +// databaseOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dolr DatabaseOperationListResult) databaseOperationListResultPreparer() (*http.Request, error) { + if dolr.NextLink == nil || len(to.String(dolr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dolr.NextLink))) +} + +// DatabaseOperationListResultPage contains a page of DatabaseOperation values. +type DatabaseOperationListResultPage struct { + fn func(DatabaseOperationListResult) (DatabaseOperationListResult, error) + dolr DatabaseOperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseOperationListResultPage) Next() error { + next, err := page.fn(page.dolr) + if err != nil { + return err + } + page.dolr = next + return nil +} + +// 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 +} + +// DatabaseOperationProperties the properties of a database operation. +type DatabaseOperationProperties struct { + // DatabaseName - The name of the database the operation is being performed on. + DatabaseName *string `json:"databaseName,omitempty"` + // Operation - The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - The operation state. Possible values include: 'Pending', 'InProgress', 'Succeeded', 'Failed', 'CancelInProgress', 'Cancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// 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 - The status of the database. Possible values include: 'Online', 'Restoring', 'RecoveryPending', 'Recovering', 'Suspect', 'Offline', 'Standby', 'Shutdown', 'EmergencyMode', 'AutoClosed', 'Copying', 'Creating', 'Inaccessible', 'OfflineSecondary', 'Pausing', 'Paused', 'Resuming', 'Scaling' + Status DatabaseStatus `json:"status,omitempty"` + // DatabaseID - The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // CreationDate - The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // CurrentServiceObjectiveName - The current service level objective name of the database. + CurrentServiceObjectiveName *string `json:"currentServiceObjectiveName,omitempty"` + // RequestedServiceObjectiveName - The requested service level objective name of the database. + RequestedServiceObjectiveName *string `json:"requestedServiceObjectiveName,omitempty"` + // DefaultSecondaryLocation - The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // FailoverGroupID - 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. Possible values include: 'LicenseIncluded', 'BasePrice' + LicenseType DatabaseLicenseType `json:"licenseType,omitempty"` + // MaxLogSizeBytes - The max log size for this database. + MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` + // EarliestRestoreDate - 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"` + // CurrentSku - The name and tier of the SKU. + CurrentSku *Sku `json:"currentSku,omitempty"` +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesDeleteFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesPauseFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesPauseFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.PauseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.PauseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesResumeFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesResumeFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.ResumeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DatabasesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return d, azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + d, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure sending request") + return + } + d, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// DatabasesUpgradeDataWarehouseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesUpgradeDataWarehouseFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future DatabasesUpgradeDataWarehouseFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.DatabasesUpgradeDataWarehouseFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.UpgradeDataWarehouseResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.UpgradeDataWarehouseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", resp, "Failure responding to request") + } + 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 +} + +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // ZoneRedundant - Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - 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"` +} + +// ElasticPool an elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + Sku *Sku `json:"sku,omitempty"` + // Kind - 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Kind != nil { + objectMap["kind"] = ep.Kind + } + 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 ep.ID != nil { + objectMap["id"] = ep.ID + } + if ep.Name != nil { + objectMap["name"] = ep.Name + } + if ep.Type != nil { + objectMap["type"] = ep.Type + } + 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 - The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolPerformanceLevels - The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolPerformanceLevels *[]ElasticPoolPerformanceLevelCapability `json:"supportedElasticPoolPerformanceLevels,omitempty"` + // ZoneRedundant - Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - 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"` +} + +// ElasticPoolListResult the result of an elastic pool list request. +type ElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]ElasticPool `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ElasticPoolListResultIterator provides access to a complete listing of ElasticPool values. +type ElasticPoolListResultIterator struct { + i int + page ElasticPoolListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ElasticPoolListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr ElasticPoolListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// elasticPoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr ElasticPoolListResult) elasticPoolListResultPreparer() (*http.Request, error) { + if eplr.NextLink == nil || len(to.String(eplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// ElasticPoolListResultPage contains a page of ElasticPool values. +type ElasticPoolListResultPage struct { + fn func(ElasticPoolListResult) (ElasticPoolListResult, error) + eplr ElasticPoolListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ElasticPoolListResultPage) Next() error { + next, err := page.fn(page.eplr) + if err != nil { + return err + } + page.eplr = next + return nil +} + +// 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 +} + +// ElasticPoolOperation a elastic pool operation. +type ElasticPoolOperation struct { + // ElasticPoolOperationProperties - Resource properties. + *ElasticPoolOperationProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if epo.ID != nil { + objectMap["id"] = epo.ID + } + if epo.Name != nil { + objectMap["name"] = epo.Name + } + if epo.Type != nil { + objectMap["type"] = epo.Type + } + 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 - Array of results. + Value *[]ElasticPoolOperation `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ElasticPoolOperationListResultIterator provides access to a complete listing of ElasticPoolOperation values. +type ElasticPoolOperationListResultIterator struct { + i int + page ElasticPoolOperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ElasticPoolOperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (epolr ElasticPoolOperationListResult) IsEmpty() bool { + return epolr.Value == nil || len(*epolr.Value) == 0 +} + +// elasticPoolOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (epolr ElasticPoolOperationListResult) elasticPoolOperationListResultPreparer() (*http.Request, error) { + if epolr.NextLink == nil || len(to.String(epolr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(epolr.NextLink))) +} + +// ElasticPoolOperationListResultPage contains a page of ElasticPoolOperation values. +type ElasticPoolOperationListResultPage struct { + fn func(ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error) + epolr ElasticPoolOperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ElasticPoolOperationListResultPage) Next() error { + next, err := page.fn(page.epolr) + if err != nil { + return err + } + page.epolr = next + return nil +} + +// 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 +} + +// ElasticPoolOperationProperties the properties of a elastic pool operation. +type ElasticPoolOperationProperties struct { + // ElasticPoolName - The name of the elastic pool the operation is being performed on. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // Operation - The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - The operation state. + State *string `json:"state,omitempty"` + // ErrorCode - The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// ElasticPoolPerDatabaseMaxPerformanceLevelCapability the max per-database performance level capability. +type ElasticPoolPerDatabaseMaxPerformanceLevelCapability struct { + // Limit - The maximum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // SupportedPerDatabaseMinPerformanceLevels - The list of supported min database performance levels. + SupportedPerDatabaseMinPerformanceLevels *[]ElasticPoolPerDatabaseMinPerformanceLevelCapability `json:"supportedPerDatabaseMinPerformanceLevels,omitempty"` + // Status - 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"` +} + +// ElasticPoolPerDatabaseMinPerformanceLevelCapability the minimum per-database performance level capability. +type ElasticPoolPerDatabaseMinPerformanceLevelCapability struct { + // Limit - The minimum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // Status - 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"` +} + +// 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 - The performance level for the pool. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // MaxDatabaseCount - The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - The included (free) max size for this performance level. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeRangeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxPerformanceLevels - The list of supported per database max performance levels. + SupportedPerDatabaseMaxPerformanceLevels *[]ElasticPoolPerDatabaseMaxPerformanceLevelCapability `json:"supportedPerDatabaseMaxPerformanceLevels,omitempty"` + // Status - 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"` +} + +// ElasticPoolProperties properties of an elastic pool +type ElasticPoolProperties struct { + // State - The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' + State ElasticPoolState `json:"state,omitempty"` + // CreationDate - 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"` +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsCreateOrUpdateFuture) Result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ElasticPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ElasticPoolsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsDeleteFuture) Result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ElasticPoolsUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ElasticPoolsUpdateFuture) Result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ep, azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ep, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure sending request") + return + } + ep, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if ifg.ID != nil { + objectMap["id"] = ifg.ID + } + if ifg.Name != nil { + objectMap["name"] = ifg.Name + } + if ifg.Type != nil { + objectMap["type"] = ifg.Type + } + 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 - Array of results. + Value *[]InstanceFailoverGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultIterator struct { + i int + page InstanceFailoverGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InstanceFailoverGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { + return ifglr.Value == nil || len(*ifglr.Value) == 0 +} + +// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer() (*http.Request, error) { + if ifglr.NextLink == nil || len(to.String(ifglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ifglr.NextLink))) +} + +// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultPage struct { + fn func(InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) + ifglr InstanceFailoverGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InstanceFailoverGroupListResultPage) Next() error { + next, err := page.fn(page.ifglr) + if err != nil { + return err + } + page.ifglr = next + return nil +} + +// 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 +} + +// 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 - Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - 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"` +} + +// 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsCreateOrUpdateFuture) Result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ifg, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ifg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ifg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstanceFailoverGroupsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsDeleteFuture) Result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstanceFailoverGroupsFailoverFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsFailoverFuture) Result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ifg, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ifg, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", resp, "Failure sending request") + return + } + ifg, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", resp, "Failure responding to request") + } + return +} + +// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsForceFailoverAllowDataLossFuture) Result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ifg, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ifg, err = client.ForceFailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") + return + } + ifg, err = client.ForceFailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } + return +} + +// LicenseTypeCapability the license type capability +type LicenseTypeCapability struct { + // Name - License type identifier. + Name *string `json:"name,omitempty"` + // Status - 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"` +} + +// LocationCapabilities the location capability. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedManagedInstanceVersions - The list of supported managed instance versions. + SupportedManagedInstanceVersions *[]ManagedInstanceVersionCapability `json:"supportedManagedInstanceVersions,omitempty"` + // Status - 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"` +} + +// LogSizeCapability the log size capability. +type LogSizeCapability struct { + // Limit - The log size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes', 'Percent' + Unit LogSizeUnit `json:"unit,omitempty"` +} + +// ManagedInstanceEditionCapability the managed server capability +type ManagedInstanceEditionCapability struct { + // Name - The managed server version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - The supported families. + SupportedFamilies *[]ManagedInstanceFamilyCapability `json:"supportedFamilies,omitempty"` + // Status - 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"` +} + +// ManagedInstanceFamilyCapability the managed server family capability. +type ManagedInstanceFamilyCapability struct { + // Name - Family name. + Name *string `json:"name,omitempty"` + // Sku - SKU name. + Sku *string `json:"sku,omitempty"` + // SupportedLicenseTypes - List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - List of supported virtual cores values. + SupportedVcoresValues *[]ManagedInstanceVcoresCapability `json:"supportedVcoresValues,omitempty"` + // IncludedMaxSize - Included size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedStorageSizes - Storage size ranges. + SupportedStorageSizes *[]MaxSizeRangeCapability `json:"supportedStorageSizes,omitempty"` + // Status - 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"` +} + +// 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"` +} + +// ManagedInstanceVcoresCapability the managed instance virtual cores capability. +type ManagedInstanceVcoresCapability struct { + // Name - The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - The virtual cores value. + Value *int32 `json:"value,omitempty"` + // Status - 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"` +} + +// ManagedInstanceVersionCapability the managed instance capability +type ManagedInstanceVersionCapability struct { + // Name - The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - The list of supported managed instance editions. + SupportedEditions *[]ManagedInstanceEditionCapability `json:"supportedEditions,omitempty"` + // Status - 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"` +} + +// MaxSizeCapability the maximum size capability. +type MaxSizeCapability struct { + // Limit - The maximum size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - The units that the limit is expressed in. Possible values include: 'MaxSizeUnitMegabytes', 'MaxSizeUnitGigabytes', 'MaxSizeUnitTerabytes', 'MaxSizeUnitPetabytes' + Unit MaxSizeUnit `json:"unit,omitempty"` +} + +// MaxSizeRangeCapability the maximum size range capability. +type MaxSizeRangeCapability struct { + // MinValue - Minimum value. + MinValue *MaxSizeCapability `json:"minValue,omitempty"` + // MaxValue - Maximum value. + MaxValue *MaxSizeCapability `json:"maxValue,omitempty"` + // ScaleSize - Scale/step size for discrete values between the minimum value and the maximum value. + ScaleSize *MaxSizeCapability `json:"scaleSize,omitempty"` + // LogSize - Size of transaction log. + LogSize *LogSizeCapability `json:"logSize,omitempty"` + // Status - 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"` +} + +// 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 - Replication role of the partner managed instances. Possible values include: 'Primary', 'Secondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// PerformanceLevelCapability the performance level capability. +type PerformanceLevelCapability struct { + // Value - Performance level value. + Value *float64 `json:"value,omitempty"` + // Unit - Unit type used to measure performance level. Possible values include: 'DTU', 'VCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// Resource ARM resource. +type Resource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// 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 - The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` + // Status - 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"` +} + +// ServiceObjectiveCapability the service objectives capability. +type ServiceObjectiveCapability struct { + // ID - The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // Name - The service objective name. + Name *string `json:"name,omitempty"` + // SupportedMaxSizes - The list of supported maximum database sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // PerformanceLevel - The performance level. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // IncludedMaxSize - The included (free) max size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // Status - 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"` +} + +// ShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ShortTermRetentionPoliciesCreateOrUpdateFuture) Result(client ShortTermRetentionPoliciesClient) (strp ShortTermRetentionPolicy, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return strp, azure.NewAsyncOpIncompleteError("sql.ShortTermRetentionPoliciesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + strp, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + strp, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ShortTermRetentionPoliciesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ShortTermRetentionPoliciesUpdateFuture) Result(client ShortTermRetentionPoliciesClient) (strp ShortTermRetentionPolicy, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return strp, azure.NewAsyncOpIncompleteError("sql.ShortTermRetentionPoliciesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + strp, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesUpdateFuture", "Result", resp, "Failure sending request") + return + } + strp, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ShortTermRetentionPolicy a short term retention policy resource. +type ShortTermRetentionPolicy struct { + autorest.Response `json:"-"` + // ShortTermRetentionPolicyProperties - Resource properties. + *ShortTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ShortTermRetentionPolicy. +func (strp ShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if strp.ShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = strp.ShortTermRetentionPolicyProperties + } + if strp.ID != nil { + objectMap["id"] = strp.ID + } + if strp.Name != nil { + objectMap["name"] = strp.Name + } + if strp.Type != nil { + objectMap["type"] = strp.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ShortTermRetentionPolicy struct. +func (strp *ShortTermRetentionPolicy) 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 shortTermRetentionPolicyProperties ShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &shortTermRetentionPolicyProperties) + if err != nil { + return err + } + strp.ShortTermRetentionPolicyProperties = &shortTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + strp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + strp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + strp.Type = &typeVar + } + } + } + + return nil +} + +// ShortTermRetentionPolicyProperties properties of a short term retention policy +type ShortTermRetentionPolicyProperties 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"` +} + +// 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 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"` +} + +// 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 - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if tr.ID != nil { + objectMap["id"] = tr.ID + } + if tr.Name != nil { + objectMap["name"] = tr.Name + } + if tr.Type != nil { + objectMap["type"] = tr.Type + } + return json.Marshal(objectMap) +} diff --git a/services/preview/sql/mgmt/2017-10-01-preview/sql/shorttermretentionpolicies.go b/services/preview/sql/mgmt/2017-10-01-preview/sql/shorttermretentionpolicies.go new file mode 100644 index 000000000000..a57857085acd --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/shorttermretentionpolicies.go @@ -0,0 +1,260 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ShortTermRetentionPoliciesClient 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 ShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewShortTermRetentionPoliciesClient creates an instance of the ShortTermRetentionPoliciesClient client. +func NewShortTermRetentionPoliciesClient(subscriptionID string) ShortTermRetentionPoliciesClient { + return NewShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewShortTermRetentionPoliciesClientWithBaseURI creates an instance of the ShortTermRetentionPoliciesClient client. +func NewShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ShortTermRetentionPoliciesClient { + return ShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database's short term retention policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the short term retention policy info. +func (client ShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ShortTermRetentionPolicy) (result ShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ShortTermRetentionPolicy) (*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 ShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's short term retention policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. +func (client ShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ShortTermRetentionPolicy, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesClient", "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.ShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ShortTermRetentionPoliciesClient) 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 ShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a database's short term retention policy. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. serverName is the name of the server. databaseName is the name of +// the database. parameters is the short term retention policy info. +func (client ShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ShortTermRetentionPolicy) (result ShortTermRetentionPoliciesUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ShortTermRetentionPoliciesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ShortTermRetentionPolicy) (*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 ShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future ShortTermRetentionPoliciesUpdateFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result ShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/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..d6e224054971 --- /dev/null +++ b/services/preview/sql/mgmt/2017-10-01-preview/sql/version.go @@ -0,0 +1,30 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " 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/sql/mgmt/2015-05-01-preview/sql/managedinstances.go b/services/sql/mgmt/2015-05-01-preview/sql/managedinstances.go new file mode 100644 index 000000000000..816c0028db69 --- /dev/null +++ b/services/sql/mgmt/2015-05-01-preview/sql/managedinstances.go @@ -0,0 +1,513 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstance, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/sql/mgmt/2015-05-01-preview/sql/models.go b/services/sql/mgmt/2015-05-01-preview/sql/models.go index fd13e96a6428..8e20a0065a76 100644 --- a/services/sql/mgmt/2015-05-01-preview/sql/models.go +++ b/services/sql/mgmt/2015-05-01-preview/sql/models.go @@ -4541,6 +4541,480 @@ type LocationCapabilities struct { Reason *string `json:"reason,omitempty"` } +// 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 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = mi.Tags + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.ID != nil { + objectMap["id"] = mi.ID + } + if mi.Name != nil { + objectMap["name"] = mi.Name + } + if mi.Type != nil { + objectMap["type"] = mi.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + 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 - Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer() (*http.Request, error) { + if milr.NextLink == nil || len(to.String(milr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceListResultPage) Next() error { + next, err := page.fn(page.milr) + if err != nil { + return err + } + page.milr = next + return nil +} + +// 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 +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // FullyQualifiedDomainName - 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 - The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' and 'BasePrice'. + LicenseType *string `json:"licenseType,omitempty"` + // VCores - The number of VCores. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - The maximum storage size in GB. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesCreateOrUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesDeleteFuture) Result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "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 - The maximum size limit (see 'unit' for the units). @@ -7044,6 +7518,20 @@ type ServiceTierAdvisorProperties struct { Confidence *float64 `json:"confidence,omitempty"` } +// 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 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 - 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' diff --git a/services/sql/mgmt/2017-03-01-preview/sql/manageddatabases.go b/services/sql/mgmt/2017-03-01-preview/sql/manageddatabases.go new file mode 100644 index 000000000000..7288a7caa861 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/manageddatabases.go @@ -0,0 +1,501 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/satori/go.uuid" + "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. +func NewManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabasesClient { + return ManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CompleteRestore completes the restore operation on a managed database. +// +// locationName is the name of the region where the resource is located. operationID is management operation id +// that this request tries to complete. parameters is the definition for completing the restore of this managed +// database. +func (client ManagedDatabasesClient) CompleteRestore(ctx context.Context, locationName string, operationID uuid.UUID, parameters CompleteDatabaseRestoreDefinition) (result ManagedDatabasesCompleteRestoreFuture, err error) { + 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, locationName, operationID, 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, locationName string, operationID uuid.UUID, parameters CompleteDatabaseRestoreDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "operationId": autorest.Encode("path", operationID), + "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}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseRestoreAzureAsyncOperation/{operationId}/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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates a new database or updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. parameters is the requested database resource state. +func (client ManagedDatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase) (result ManagedDatabasesCreateOrUpdateFuture, err error) { + 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 = "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}", 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. +func (client ManagedDatabasesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabasesDeleteFuture, err error) { + 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 = "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}/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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. +func (client ManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabase, err error) { + 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 +} + +// 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 = "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}", 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) GetResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed databases. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultPage, err error) { + 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 +} + +// 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 = "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", 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedDatabaseListResult) (result ManagedDatabaseListResult, err error) { + req, err := lastResults.managedDatabaseListResultPreparer() + 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) { + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Update updates an existing database. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// databaseName is the name of the database. parameters is the requested database resource state. +func (client ManagedDatabasesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseUpdate) (result ManagedDatabasesUpdateFuture, err error) { + 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 = "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}", 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) UpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/managedinstances.go b/services/sql/mgmt/2017-03-01-preview/sql/managedinstances.go new file mode 100644 index 000000000000..816c0028db69 --- /dev/null +++ b/services/sql/mgmt/2017-03-01-preview/sql/managedinstances.go @@ -0,0 +1,513 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstance, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ManagedInstanceListResultPage, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer() + 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) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. managedInstanceName is the name of the managed instance. +// parameters is the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/sql/mgmt/2017-03-01-preview/sql/models.go b/services/sql/mgmt/2017-03-01-preview/sql/models.go index 27b9581738ef..7328036c059d 100644 --- a/services/sql/mgmt/2017-03-01-preview/sql/models.go +++ b/services/sql/mgmt/2017-03-01-preview/sql/models.go @@ -201,6 +201,21 @@ 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 @@ -406,6 +421,44 @@ func PossibleIdentityTypeValues() []IdentityType { return []IdentityType{SystemAssigned} } +// ManagedDatabaseCreateMode enumerates the values for managed database create mode. +type ManagedDatabaseCreateMode string + +const ( + // ManagedDatabaseCreateModeDefault ... + ManagedDatabaseCreateModeDefault ManagedDatabaseCreateMode = "Default" + // ManagedDatabaseCreateModePointInTimeRestore ... + ManagedDatabaseCreateModePointInTimeRestore ManagedDatabaseCreateMode = "PointInTimeRestore" + // ManagedDatabaseCreateModeRestoreExternalBackup ... + ManagedDatabaseCreateModeRestoreExternalBackup ManagedDatabaseCreateMode = "RestoreExternalBackup" +) + +// PossibleManagedDatabaseCreateModeValues returns an array of possible values for the ManagedDatabaseCreateMode const type. +func PossibleManagedDatabaseCreateModeValues() []ManagedDatabaseCreateMode { + return []ManagedDatabaseCreateMode{ManagedDatabaseCreateModeDefault, ManagedDatabaseCreateModePointInTimeRestore, ManagedDatabaseCreateModeRestoreExternalBackup} +} + +// 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" + // Shutdown ... + Shutdown ManagedDatabaseStatus = "Shutdown" +) + +// PossibleManagedDatabaseStatusValues returns an array of possible values for the ManagedDatabaseStatus const type. +func PossibleManagedDatabaseStatusValues() []ManagedDatabaseStatus { + return []ManagedDatabaseStatus{Creating, Inaccessible, Offline, Online, Shutdown} +} + // ManagementOperationState enumerates the values for management operation state. type ManagementOperationState string @@ -920,17 +973,17 @@ func PossibleStorageKeyTypeValues() []StorageKeyType { type SyncAgentState string const ( - // NeverConnected ... - NeverConnected SyncAgentState = "NeverConnected" - // Offline ... - Offline SyncAgentState = "Offline" - // Online ... - Online SyncAgentState = "Online" + // 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{NeverConnected, Offline, Online} + return []SyncAgentState{SyncAgentStateNeverConnected, SyncAgentStateOffline, SyncAgentStateOnline} } // SyncConflictResolutionPolicy enumerates the values for sync conflict resolution policy. @@ -1553,6 +1606,13 @@ type CheckNameAvailabilityResponse struct { Reason CheckNameAvailabilityReason `json:"reason,omitempty"` } +// 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 { @@ -5134,164 +5194,134 @@ type LocationCapabilities struct { SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` } -// MaxSizeCapability the maximum size limits for a database. -type MaxSizeCapability struct { - // Limit - The maximum size of the database (see 'unit' for the units). - Limit *int64 `json:"limit,omitempty"` - // Unit - The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes' - Unit MaxSizeUnits `json:"unit,omitempty"` - // Status - The status of the maximum size capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' - Status CapabilityStatus `json:"status,omitempty"` -} - -// Metric database metrics. -type Metric struct { - // StartTime - The start time for the metric (ISO-8601 format). - StartTime *date.Time `json:"startTime,omitempty"` - // EndTime - The end time for the metric (ISO-8601 format). - EndTime *date.Time `json:"endTime,omitempty"` - // TimeGrain - The time step to be used to summarize the metric values. - TimeGrain *string `json:"timeGrain,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' - Unit UnitType `json:"unit,omitempty"` - // Name - The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // MetricValues - The metric values for the specified time window and timestep. - MetricValues *[]MetricValue `json:"metricValues,omitempty"` -} - -// MetricAvailability a metric availability value. -type MetricAvailability struct { - // Retention - The length of retention for the database metric. - Retention *string `json:"retention,omitempty"` - // TimeGrain - The granularity of the database metric. - TimeGrain *string `json:"timeGrain,omitempty"` -} - -// MetricDefinition a database metric definition. -type MetricDefinition struct { - // Name - The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // PrimaryAggregationType - The primary aggregation type defining how metric values are displayed. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' - PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` - // ResourceURI - The resource uri of the database. - ResourceURI *string `json:"resourceUri,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' - Unit UnitDefinitionType `json:"unit,omitempty"` - // MetricAvailabilities - The list of database metric availabities for the metric. - MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` -} - -// 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 { +// ManagedDatabase a managed database resource. +type ManagedDatabase 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 - The name of the database metric. - Value *string `json:"value,omitempty"` - // LocalizedValue - The friendly name of the database metric. - LocalizedValue *string `json:"localizedValue,omitempty"` -} - -// MetricValue represents database metrics. -type MetricValue struct { - // Count - The number of values for the metric. - Count *float64 `json:"count,omitempty"` - // Average - The average value of the metric. - Average *float64 `json:"average,omitempty"` - // Maximum - The max value of the metric. - Maximum *float64 `json:"maximum,omitempty"` - // Minimum - The min value of the metric. - Minimum *float64 `json:"minimum,omitempty"` - // Timestamp - The metric timestamp (ISO-8601 format). - Timestamp *date.Time `json:"timestamp,omitempty"` - // Total - The total value of the metric. - Total *float64 `json:"total,omitempty"` -} - -// Operation SQL REST API operation definition. -type Operation struct { - // Name - The name of the operation being performed on this particular object. + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. Name *string `json:"name,omitempty"` - // Display - The localized display information for this particular operation / action. - Display *OperationDisplay `json:"display,omitempty"` - // Origin - The intended executor of the operation. Possible values include: 'OperationOriginUser', 'OperationOriginSystem' - Origin OperationOrigin `json:"origin,omitempty"` - // Properties - Additional descriptions for the operation. - Properties map[string]interface{} `json:"properties"` + // Type - Resource type. + Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for Operation. -func (o Operation) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for ManagedDatabase. +func (md ManagedDatabase) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if o.Name != nil { - objectMap["name"] = o.Name + if md.ManagedDatabaseProperties != nil { + objectMap["properties"] = md.ManagedDatabaseProperties } - if o.Display != nil { - objectMap["display"] = o.Display + if md.Tags != nil { + objectMap["tags"] = md.Tags } - if o.Origin != "" { - objectMap["origin"] = o.Origin + if md.Location != nil { + objectMap["location"] = md.Location } - if o.Properties != nil { - objectMap["properties"] = o.Properties + if md.ID != nil { + objectMap["id"] = md.ID + } + if md.Name != nil { + objectMap["name"] = md.Name + } + if md.Type != nil { + objectMap["type"] = md.Type } return json.Marshal(objectMap) } -// OperationDisplay display metadata associated with the operation. -type OperationDisplay struct { - // Provider - The localized friendly form of the resource provider name. - Provider *string `json:"provider,omitempty"` - // Resource - The localized friendly form of the resource type related to this action/operation. - Resource *string `json:"resource,omitempty"` - // Operation - The localized friendly name for the operation. - Operation *string `json:"operation,omitempty"` - // Description - The localized friendly description for the operation. - Description *string `json:"description,omitempty"` -} +// 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + md.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + md.Location = &location + } + 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 + } + } + } -// OperationImpact the impact of an operation, both in absolute and relative terms. -type OperationImpact struct { - // Name - The name of the impact dimension. - Name *string `json:"name,omitempty"` - // Unit - The unit in which estimated impact to dimension is measured. - Unit *string `json:"unit,omitempty"` - // ChangeValueAbsolute - The absolute impact to dimension. - ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` - // ChangeValueRelative - The relative impact to dimension (null if not applicable) - ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` + return nil } -// OperationListResult result of the request to list SQL operations. -type OperationListResult struct { +// ManagedDatabaseListResult a list of managed databases. +type ManagedDatabaseListResult struct { autorest.Response `json:"-"` // Value - Array of results. - Value *[]Operation `json:"value,omitempty"` + Value *[]ManagedDatabase `json:"value,omitempty"` // NextLink - Link to retrieve next page of results. NextLink *string `json:"nextLink,omitempty"` } -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { +// ManagedDatabaseListResultIterator provides access to a complete listing of ManagedDatabase values. +type ManagedDatabaseListResultIterator struct { i int - page OperationListResultPage + page ManagedDatabaseListResultPage } // Next advances to the next value. If there was an error making // the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) Next() error { +func (iter *ManagedDatabaseListResultIterator) Next() error { iter.i++ if iter.i < len(iter.page.Values()) { return nil @@ -5306,84 +5336,1077 @@ func (iter *OperationListResultIterator) Next() error { } // NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { +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 OperationListResultIterator) Value() Operation { +func (iter ManagedDatabaseListResultIterator) Value() ManagedDatabase { if !iter.page.NotDone() { - return Operation{} + return ManagedDatabase{} } return iter.page.Values()[iter.i] } // IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 +func (mdlr ManagedDatabaseListResult) IsEmpty() bool { + return mdlr.Value == nil || len(*mdlr.Value) == 0 } -// operationListResultPreparer 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 (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { +func (mdlr ManagedDatabaseListResult) managedDatabaseListResultPreparer() (*http.Request, error) { + if mdlr.NextLink == nil || len(to.String(mdlr.NextLink)) < 1 { return nil, nil } return autorest.Prepare(&http.Request{}, autorest.AsJSON(), autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) + autorest.WithBaseURL(to.String(mdlr.NextLink))) } -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(OperationListResult) (OperationListResult, error) - olr OperationListResult +// ManagedDatabaseListResultPage contains a page of ManagedDatabase values. +type ManagedDatabaseListResultPage struct { + fn func(ManagedDatabaseListResult) (ManagedDatabaseListResult, error) + mdlr ManagedDatabaseListResult } // Next advances to the next page of values. If there was an error making // the request the page does not advance and the error is returned. -func (page *OperationListResultPage) Next() error { - next, err := page.fn(page.olr) +func (page *ManagedDatabaseListResultPage) Next() error { + next, err := page.fn(page.mdlr) if err != nil { return err } - page.olr = next + page.mdlr = next return nil } // NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() +func (page ManagedDatabaseListResultPage) NotDone() bool { + return !page.mdlr.IsEmpty() } // Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr +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 OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { +func (page ManagedDatabaseListResultPage) Values() []ManagedDatabase { + if page.mdlr.IsEmpty() { return nil } - return *page.olr.Value + return *page.mdlr.Value } -// PartnerInfo partner server information for the failover group. -type PartnerInfo struct { - // ID - Resource identifier of the partner server. - ID *string `json:"id,omitempty"` - // Location - Geo location of the partner server. - Location *string `json:"location,omitempty"` - // ReplicationRole - Replication role of the partner server. Possible values include: 'Primary', 'Secondary' - ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` +// ManagedDatabaseProperties the managed database's properties. +type ManagedDatabaseProperties struct { + // Collation - Collation of the managed database. + Collation *string `json:"collation,omitempty"` + // Status - Status for the database. Possible values include: 'Online', 'Offline', 'Shutdown', 'Creating', 'Inaccessible' + Status ManagedDatabaseStatus `json:"status,omitempty"` + // CreationDate - Creation date of the database. + CreationDate *date.Time `json:"creationDate,omitempty"` + // EarliestRestorePoint - 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 - 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. Possible values include: 'ManagedDatabaseCreateModeDefault', 'ManagedDatabaseCreateModeRestoreExternalBackup', 'ManagedDatabaseCreateModePointInTimeRestore' + 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"` + // StorageContainerSasToken - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. + StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` + // FailoverGroupID - Instance Failover Group resource identifier that this managed database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` +} + +// ManagedDatabasesCompleteRestoreFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesCompleteRestoreFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesCompleteRestoreFuture) Result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCompleteRestoreFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.CompleteRestoreResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.CompleteRestoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedDatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesCreateOrUpdateFuture) Result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return md, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + md, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + md, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedDatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesDeleteFuture) Result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedDatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedDatabasesUpdateFuture) Result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return md, azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + md, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", resp, "Failure sending request") + return + } + md, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", resp, "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 +} + +// 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 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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.Tags != nil { + objectMap["tags"] = mi.Tags + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.ID != nil { + objectMap["id"] = mi.ID + } + if mi.Name != nil { + objectMap["name"] = mi.Name + } + if mi.Type != nil { + objectMap["type"] = mi.Type + } + 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + 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 - Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer() (*http.Request, error) { + if milr.NextLink == nil || len(to.String(milr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceListResultPage) Next() error { + next, err := page.fn(page.milr) + if err != nil { + return err + } + page.milr = next + return nil +} + +// 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 +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // FullyQualifiedDomainName - 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 - The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' and 'BasePrice'. + LicenseType *string `json:"licenseType,omitempty"` + // VCores - The number of VCores. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - The maximum storage size in GB. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesCreateOrUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesDeleteFuture) Result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future ManagedInstancesUpdateFuture) Result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return mi, azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + mi, err = client.UpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "Failure sending request") + return + } + mi, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", resp, "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 limits for a database. +type MaxSizeCapability struct { + // Limit - The maximum size of the database (see 'unit' for the units). + Limit *int64 `json:"limit,omitempty"` + // Unit - The units that the limit is expressed in. Possible values include: 'Megabytes', 'Gigabytes', 'Terabytes', 'Petabytes' + Unit MaxSizeUnits `json:"unit,omitempty"` + // Status - The status of the maximum size capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` +} + +// Metric database metrics. +type Metric struct { + // StartTime - The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - The time step to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' + Unit UnitType `json:"unit,omitempty"` + // Name - The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MetricAvailability a metric availability value. +type MetricAvailability struct { + // Retention - The length of retention for the database metric. + Retention *string `json:"retention,omitempty"` + // TimeGrain - The granularity of the database metric. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MetricDefinition a database metric definition. +type MetricDefinition struct { + // Name - The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // PrimaryAggregationType - The primary aggregation type defining how metric values are displayed. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // ResourceURI - The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' + Unit UnitDefinitionType `json:"unit,omitempty"` + // MetricAvailabilities - The list of database metric availabities for the metric. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` +} + +// 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 - The name of the database metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - The friendly name of the database metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MetricValue represents database metrics. +type MetricValue struct { + // Count - The number of values for the metric. + Count *float64 `json:"count,omitempty"` + // Average - The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// Operation SQL REST API operation definition. +type Operation struct { + // Name - The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - The localized display information for this particular operation / action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The intended executor of the operation. Possible values include: 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - 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{}) + if o.Name != nil { + objectMap["name"] = o.Name + } + if o.Display != nil { + objectMap["display"] = o.Display + } + if o.Origin != "" { + objectMap["origin"] = o.Origin + } + if o.Properties != nil { + objectMap["properties"] = o.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - The localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - The localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` + // Operation - The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - The localized friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// OperationImpact the impact of an operation, both in absolute and relative terms. +type OperationImpact struct { + // Name - The name of the impact dimension. + Name *string `json:"name,omitempty"` + // Unit - The unit in which estimated impact to dimension is measured. + Unit *string `json:"unit,omitempty"` + // ChangeValueAbsolute - The absolute impact to dimension. + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - The relative impact to dimension (null if not applicable) + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// OperationListResult result of the request to list SQL operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - Array of results. + Value *[]Operation `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// 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 +} + +// PartnerInfo partner server information for the failover group. +type PartnerInfo struct { + // ID - Resource identifier of the partner server. + ID *string `json:"id,omitempty"` + // Location - Geo location of the partner server. + Location *string `json:"location,omitempty"` + // ReplicationRole - Replication role of the partner server. Possible values include: 'Primary', 'Secondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` } // PerformanceLevel a possible performance level of a service objective capability. @@ -8222,6 +9245,20 @@ type ServiceTierAdvisorProperties struct { Confidence *float64 `json:"confidence,omitempty"` } +// 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 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 - 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' @@ -8827,7 +9864,7 @@ type SyncAgentProperties struct { SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` // LastAliveTime - Last alive time of the sync agent. LastAliveTime *date.Time `json:"lastAliveTime,omitempty"` - // State - State of the sync agent. Possible values include: 'Online', 'Offline', 'NeverConnected' + // State - State of the sync agent. Possible values include: 'SyncAgentStateOnline', 'SyncAgentStateOffline', 'SyncAgentStateNeverConnected' State SyncAgentState `json:"state,omitempty"` // IsUpToDate - If the sync agent version is up to date. IsUpToDate *bool `json:"isUpToDate,omitempty"` diff --git a/services/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go b/services/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go new file mode 100644 index 000000000000..e82ba319e2fc --- /dev/null +++ b/services/sql/mgmt/2017-10-01-preview/sql/instancefailovergroups.go @@ -0,0 +1,504 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// 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. +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return InstanceFailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. parameters is the failover group parameters. +func (client InstanceFailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (result InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsDeleteFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary managed instance to this managed instance. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsFailoverFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + 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. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + 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) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is the name of the region where the resource is +// located. failoverGroupName is the name of the failover group. +func (client InstanceFailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroup, err error) { + 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 +} + +// 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 autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) GetResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists the failover groups in a location. +// +// resourceGroupName is the name of the resource group that contains the resource. You can obtain this value from +// the Azure Resource Manager API or the portal. locationName is 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) { + 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 +} + +// 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + 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(lastResults InstanceFailoverGroupListResult) (result InstanceFailoverGroupListResult, err error) { + req, err := lastResults.instanceFailoverGroupListResultPreparer() + 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) { + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + return +} diff --git a/services/sql/mgmt/2017-10-01-preview/sql/models.go b/services/sql/mgmt/2017-10-01-preview/sql/models.go index a9d92dbce2bf..798dc3051fb5 100644 --- a/services/sql/mgmt/2017-10-01-preview/sql/models.go +++ b/services/sql/mgmt/2017-10-01-preview/sql/models.go @@ -20,11 +20,27 @@ package sql import ( "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" "net/http" ) +// 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} +} + // ManagementOperationState enumerates the values for management operation state. type ManagementOperationState string @@ -48,6 +64,36 @@ func PossibleManagementOperationStateValues() []ManagementOperationState { return []ManagementOperationState{CancelInProgress, Cancelled, Failed, InProgress, Pending, Succeeded} } +// ReadOnlyEndpointFailoverPolicy enumerates the values for read only endpoint failover policy. +type ReadOnlyEndpointFailoverPolicy string + +const ( + // Disabled ... + Disabled ReadOnlyEndpointFailoverPolicy = "Disabled" + // Enabled ... + Enabled ReadOnlyEndpointFailoverPolicy = "Enabled" +) + +// PossibleReadOnlyEndpointFailoverPolicyValues returns an array of possible values for the ReadOnlyEndpointFailoverPolicy const type. +func PossibleReadOnlyEndpointFailoverPolicyValues() []ReadOnlyEndpointFailoverPolicy { + return []ReadOnlyEndpointFailoverPolicy{Disabled, Enabled} +} + +// 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} +} + // DatabaseOperation a database operation. type DatabaseOperation struct { // DatabaseOperationProperties - Resource properties. @@ -478,6 +524,432 @@ type ElasticPoolOperationProperties struct { IsCancellable *bool `json:"isCancellable,omitempty"` } +// InstanceFailoverGroup an instance failover group. +type InstanceFailoverGroup struct { + autorest.Response `json:"-"` + // InstanceFailoverGroupProperties - Resource properties. + *InstanceFailoverGroupProperties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - 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 + } + if ifg.ID != nil { + objectMap["id"] = ifg.ID + } + if ifg.Name != nil { + objectMap["name"] = ifg.Name + } + if ifg.Type != nil { + objectMap["type"] = ifg.Type + } + 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 - Array of results. + Value *[]InstanceFailoverGroup `json:"value,omitempty"` + // NextLink - Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultIterator struct { + i int + page InstanceFailoverGroupListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InstanceFailoverGroupListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { + return ifglr.Value == nil || len(*ifglr.Value) == 0 +} + +// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer() (*http.Request, error) { + if ifglr.NextLink == nil || len(to.String(ifglr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ifglr.NextLink))) +} + +// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultPage struct { + fn func(InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) + ifglr InstanceFailoverGroupListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InstanceFailoverGroupListResultPage) Next() error { + next, err := page.fn(page.ifglr) + if err != nil { + return err + } + page.ifglr = next + return nil +} + +// 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 +} + +// 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 - Local replication role of the failover group instance. Possible values include: 'Primary', 'Secondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - 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"` +} + +// 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: 'Disabled', 'Enabled' + 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.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsCreateOrUpdateFuture) Result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ifg, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ifg, err = client.CreateOrUpdateResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure sending request") + return + } + ifg, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", resp, "Failure responding to request") + } + return +} + +// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstanceFailoverGroupsDeleteFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsDeleteFuture) Result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ar, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ar, err = client.DeleteResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", resp, "Failure sending request") + return + } + ar, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", resp, "Failure responding to request") + } + return +} + +// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstanceFailoverGroupsFailoverFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsFailoverFuture) Result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ifg, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ifg, err = client.FailoverResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", resp, "Failure sending request") + return + } + ifg, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", resp, "Failure responding to request") + } + return +} + +// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future InstanceFailoverGroupsForceFailoverAllowDataLossFuture) Result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return ifg, azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") + } + if future.PollingMethod() == azure.PollingLocation { + ifg, err = client.ForceFailoverAllowDataLossResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure sending request") + return + } + ifg, err = client.ForceFailoverAllowDataLossResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", resp, "Failure responding to request") + } + 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"` +} + +// 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 - Replication role of the partner managed instances. Possible values include: 'Primary', 'Secondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + // ProxyResource ARM proxy resource. type ProxyResource struct { // ID - Resource ID.